2017-09-10 09:58:38 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-05-02 18:58:48 +02:00
|
|
|
RSpec.describe BootstrapTimelineService, type: :service do
|
2017-09-10 09:58:38 +02:00
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
describe '#call' do
|
|
|
|
let(:source_account) { Fabricate(:account) }
|
|
|
|
|
|
|
|
context 'when setting is empty' do
|
|
|
|
let!(:admin) { Fabricate(:user, admin: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Setting.bootstrap_timeline_accounts = nil
|
|
|
|
subject.call(source_account)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'follows admin accounts from account' do
|
|
|
|
expect(source_account.following?(admin.account)).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when setting is set' do
|
|
|
|
let!(:alice) { Fabricate(:account, username: 'alice') }
|
|
|
|
let!(:bob) { Fabricate(:account, username: 'bob') }
|
2019-10-01 15:10:00 +02:00
|
|
|
let!(:eve) { Fabricate(:account, username: 'eve', suspended: true) }
|
2017-09-10 09:58:38 +02:00
|
|
|
|
|
|
|
before do
|
2019-10-01 15:10:00 +02:00
|
|
|
Setting.bootstrap_timeline_accounts = 'alice, @bob, eve, unknown'
|
2017-09-10 09:58:38 +02:00
|
|
|
subject.call(source_account)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'follows found accounts from account' do
|
|
|
|
expect(source_account.following?(alice)).to be true
|
|
|
|
expect(source_account.following?(bob)).to be true
|
|
|
|
end
|
2019-10-01 15:10:00 +02:00
|
|
|
|
|
|
|
it 'does not follow suspended account' do
|
|
|
|
expect(source_account.following?(eve)).to be false
|
|
|
|
end
|
2017-09-10 09:58:38 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|