fan_out_on_write_service_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. require 'rails_helper'
  2. RSpec.describe FanOutOnWriteService, type: :service do
  3. let(:author) { Fabricate(:account, username: 'tom') }
  4. let(:status) { Fabricate(:status, text: 'Hello @alice #test', account: author) }
  5. let(:alice) { Fabricate(:user, account: Fabricate(:account, username: 'alice')).account }
  6. let(:follower) { Fabricate(:account, username: 'bob') }
  7. subject { FanOutOnWriteService.new }
  8. before do
  9. alice
  10. follower.follow!(author)
  11. ProcessMentionsService.new.call(status)
  12. ProcessHashtagsService.new.call(status)
  13. subject.call(status)
  14. end
  15. it 'delivers status to home timeline' do
  16. expect(HomeFeed.new(author).get(10).map(&:id)).to include status.id
  17. end
  18. it 'delivers status to local followers' do
  19. pending 'some sort of problem in test environment causes this to sometimes fail'
  20. expect(HomeFeed.new(follower).get(10).map(&:id)).to include status.id
  21. end
  22. it 'delivers status to hashtag' do
  23. expect(TagFeed.new(Tag.find_by(name: 'test'), alice).get(20).map(&:id)).to include status.id
  24. end
  25. it 'delivers status to public timeline' do
  26. expect(PublicFeed.new(alice).get(20).map(&:id)).to include status.id
  27. end
  28. end