2016-03-19 11:13:47 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-05-02 17:58:48 +01:00
|
|
|
RSpec.describe FanOutOnWriteService, type: :service do
|
2016-11-06 14:56:34 +00:00
|
|
|
let(:author) { Fabricate(:account, username: 'tom') }
|
|
|
|
let(:status) { Fabricate(:status, text: 'Hello @alice #test', account: author) }
|
|
|
|
let(:alice) { Fabricate(:user, account: Fabricate(:account, username: 'alice')).account }
|
|
|
|
let(:follower) { Fabricate(:account, username: 'bob') }
|
|
|
|
|
2016-03-19 11:13:47 +00:00
|
|
|
subject { FanOutOnWriteService.new }
|
2016-11-06 14:56:34 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
alice
|
|
|
|
follower.follow!(author)
|
|
|
|
|
|
|
|
ProcessMentionsService.new.call(status)
|
|
|
|
ProcessHashtagsService.new.call(status)
|
|
|
|
|
|
|
|
subject.call(status)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to home timeline' do
|
2017-11-17 23:16:48 +00:00
|
|
|
expect(HomeFeed.new(author).get(10).map(&:id)).to include status.id
|
2016-11-06 14:56:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to local followers' do
|
2017-04-04 20:14:44 +01:00
|
|
|
pending 'some sort of problem in test environment causes this to sometimes fail'
|
2017-11-17 23:16:48 +00:00
|
|
|
expect(HomeFeed.new(follower).get(10).map(&:id)).to include status.id
|
2016-11-06 14:56:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to hashtag' do
|
2020-09-07 10:02:04 +01:00
|
|
|
expect(TagFeed.new(Tag.find_by(name: 'test'), alice).get(20).map(&:id)).to include status.id
|
2016-11-06 14:56:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to public timeline' do
|
2020-09-07 10:02:04 +01:00
|
|
|
expect(PublicFeed.new(alice).get(20).map(&:id)).to include status.id
|
2016-11-06 14:56:34 +00:00
|
|
|
end
|
2016-03-19 11:13:47 +00:00
|
|
|
end
|