1
0

favourite_spec.rb 946 B

1234567891011121314151617181920212223242526272829
  1. require 'rails_helper'
  2. RSpec.describe Favourite, type: :model do
  3. let(:account) { Fabricate(:account) }
  4. context 'when status is a reblog' do
  5. let(:reblog) { Fabricate(:status, reblog: nil) }
  6. let(:status) { Fabricate(:status, reblog: reblog) }
  7. it 'invalidates if the reblogged status is already a favourite' do
  8. Favourite.create!(account: account, status: reblog)
  9. expect(Favourite.new(account: account, status: status).valid?).to eq false
  10. end
  11. it 'replaces status with the reblogged one if it is a reblog' do
  12. favourite = Favourite.create!(account: account, status: status)
  13. expect(favourite.status).to eq reblog
  14. end
  15. end
  16. context 'when status is not a reblog' do
  17. let(:status) { Fabricate(:status, reblog: nil) }
  18. it 'saves with the specified status' do
  19. favourite = Favourite.create!(account: account, status: status)
  20. expect(favourite.status).to eq status
  21. end
  22. end
  23. end