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.

37 lines
1.1 KiB

  1. require 'rails_helper'
  2. RSpec.describe FanOutOnWriteService 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(Feed.new(:home, 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(Feed.new(:home, follower).get(10).map(&:id)).to include status.id
  21. end
  22. it 'delivers status to hashtag' do
  23. expect(Tag.find_by!(name: 'test').statuses.pluck(:id)).to include status.id
  24. end
  25. it 'delivers status to public timeline' do
  26. expect(Status.as_public_timeline(alice).map(&:id)).to include status.id
  27. end
  28. end