闭社主体 forked from https://github.com/tootsuite/mastodon
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.

43 lines
1.3 KiB

  1. require 'rails_helper'
  2. RSpec.describe StreamEntry, type: :model do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. let(:bob) { Fabricate(:account, username: 'bob') }
  5. let(:follow) { Fabricate(:follow, account: alice, target_account: bob) }
  6. let(:status) { Fabricate(:status, account: alice) }
  7. let(:reblog) { Fabricate(:status, account: bob, reblog: status) }
  8. let(:reply) { Fabricate(:status, account: bob, thread: status) }
  9. let(:favourite) { Fabricate(:favourite, account: alice, status: status) }
  10. describe '#targeted?' do
  11. it 'returns true for a follow' do
  12. expect(follow.stream_entry.targeted?).to be true
  13. end
  14. it 'returns true for a favourite' do
  15. expect(favourite.stream_entry.targeted?).to be true
  16. end
  17. it 'returns true for a reblog' do
  18. expect(reblog.stream_entry.targeted?).to be true
  19. end
  20. it 'returns false otherwise' do
  21. expect(status.stream_entry.targeted?).to be false
  22. end
  23. end
  24. describe '#threaded?' do
  25. it 'returns true for a favourite' do
  26. expect(favourite.stream_entry.threaded?).to be true
  27. end
  28. it 'returns true for a reply' do
  29. expect(reply.stream_entry.threaded?).to be true
  30. end
  31. it 'returns false otherwise' do
  32. expect(status.stream_entry.threaded?).to be false
  33. end
  34. end
  35. end