2016-03-19 22:13:47 +11:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe FanOutOnWriteService do
|
2016-11-07 01:56:34 +11: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 22:13:47 +11:00
|
|
|
subject { FanOutOnWriteService.new }
|
2016-11-07 01:56:34 +11: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
|
2016-11-19 09:08:52 +11:00
|
|
|
expect(Feed.new(:home, author).get(10).map(&:id)).to include status.id
|
2016-11-07 01:56:34 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to local followers' do
|
2016-11-19 09:08:52 +11:00
|
|
|
expect(Feed.new(:home, follower).get(10).map(&:id)).to include status.id
|
2016-11-07 01:56:34 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to hashtag' do
|
|
|
|
expect(Tag.find_by!(name: 'test').statuses.pluck(:id)).to include status.id
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers status to public timeline' do
|
|
|
|
expect(Status.as_public_timeline(alice).map(&:id)).to include status.id
|
|
|
|
end
|
2016-03-19 22:13:47 +11:00
|
|
|
end
|