mastodon/spec/services/fan_out_on_write_service_spec.rb
Eugen Rochko 24cafd73a2
Lists (#5703)
* Add structure for lists

* Add list timeline streaming API

* Add list APIs, bind list-account relation to follow relation

* Add API for adding/removing accounts from lists

* Add pagination to lists API

* Add pagination to list accounts API

* Adjust scopes for new APIs

- Creating and modifying lists merely requires "write" scope
- Fetching information about lists merely requires "read" scope

* Add test for wrong user context on list timeline

* Clean up tests
2017-11-18 00:16:48 +01:00

38 lines
1.1 KiB
Ruby

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(HomeFeed.new(author).get(10).map(&:id)).to include status.id
end
it 'delivers status to local followers' do
pending 'some sort of problem in test environment causes this to sometimes fail'
expect(HomeFeed.new(follower).get(10).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