闭社主体 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.

40 lines
1.2 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. expect(Feed.new(:home, follower).get(10).map(&:id)).to include status.id
  20. end
  21. it 'delivers status to mentioned users' do
  22. expect(Feed.new(:mentions, alice).get(10).map(&:id)).to include status.id
  23. end
  24. it 'delivers status to hashtag' do
  25. expect(Tag.find_by!(name: 'test').statuses.pluck(:id)).to include status.id
  26. end
  27. it 'delivers status to public timeline' do
  28. expect(Status.as_public_timeline(alice).map(&:id)).to include status.id
  29. end
  30. end