diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-06 15:56:34 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-06 15:56:34 +0100 |
commit | 93212bc2c45eb06bdb1eb1f05a69701001a2a1fb (patch) | |
tree | c489b7ebabe964cfba85c00e083d0f70fb95c760 /spec/services | |
parent | 7bb28bf7804eadbaeac05e7adb8123a8fb6c5d02 (diff) |
Add test for FanOutOnWriteService
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/fan_out_on_write_service_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 2b087edd9..36bfcda16 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -1,5 +1,40 @@ require 'rails_helper' RSpec.describe FanOutOnWriteService do + 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') } + subject { FanOutOnWriteService.new } + + 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 + expect(Feed.new(:home, author).get(1).map(&:id)).to include status.id + end + + it 'delivers status to local followers' do + expect(Feed.new(:home, follower).get(1).map(&:id)).to include status.id + end + + it 'delivers status to mentioned users' do + expect(Feed.new(:mentions, alice).get(1).map(&:id)).to include status.id + 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 end |