1
0

favourite_spec.rb 987 B

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