bookmark_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Bookmark do
  4. describe 'Associations' do
  5. it { is_expected.to belong_to(:account).required }
  6. it { is_expected.to belong_to(:status).required }
  7. end
  8. describe 'Validations' do
  9. subject { Fabricate.build :bookmark }
  10. it { is_expected.to validate_uniqueness_of(:status_id).scoped_to(:account_id) }
  11. end
  12. describe 'Callbacks' do
  13. describe 'reblog statuses' do
  14. context 'when status is not a reblog' do
  15. let(:status) { Fabricate :status }
  16. it 'keeps status set to assigned value' do
  17. bookmark = Fabricate.build :bookmark, status: status
  18. expect { bookmark.valid? }
  19. .to_not change(bookmark, :status)
  20. end
  21. end
  22. context 'when status is a reblog' do
  23. let(:original) { Fabricate :status }
  24. let(:status) { Fabricate :status, reblog: original }
  25. it 'keeps status set to assigned value' do
  26. bookmark = Fabricate.build :bookmark, status: status
  27. expect { bookmark.valid? }
  28. .to change(bookmark, :status).to(original)
  29. end
  30. end
  31. end
  32. end
  33. end