You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. require 'rails_helper'
  2. RSpec.describe Favourite, type: :model do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. let(:bob) { Fabricate(:account, username: 'bob') }
  5. let(:status) { Fabricate(:status, account: bob) }
  6. subject { Favourite.new(account: alice, status: status) }
  7. describe '#verb' do
  8. it 'is always favorite' do
  9. expect(subject.verb).to be :favorite
  10. end
  11. end
  12. describe '#title' do
  13. it 'describes the favourite' do
  14. expect(subject.title).to eql 'alice favourited a status by bob'
  15. end
  16. end
  17. describe '#content' do
  18. it 'equals the title' do
  19. expect(subject.content).to eq subject.title
  20. end
  21. end
  22. describe '#object_type' do
  23. it 'is a note when the target is a note' do
  24. expect(subject.object_type).to be :note
  25. end
  26. it 'is a comment when the target is a comment' do
  27. status.in_reply_to_id = 2
  28. expect(subject.object_type).to be :comment
  29. end
  30. end
  31. describe '#target' do
  32. it 'is the status that was favourited' do
  33. expect(subject.target).to eq status
  34. end
  35. end
  36. describe '#thread' do
  37. it 'equals the target' do
  38. expect(subject.thread).to eq subject.target
  39. end
  40. end
  41. end