mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 13:43:41 +01:00
b5ac61b2c5
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Scheduler::FollowRecommendationsScheduler do
|
|
let!(:target_accounts) do
|
|
Fabricate.times(3, :account) do
|
|
statuses(count: 6)
|
|
end
|
|
end
|
|
let!(:follower_accounts) do
|
|
Fabricate.times(5, :account) do
|
|
statuses(count: 6)
|
|
end
|
|
end
|
|
|
|
describe '#perform' do
|
|
subject(:scheduled_run) { described_class.new.perform }
|
|
|
|
context 'when there are accounts to recommend' do
|
|
before do
|
|
# Follow the target accounts by follow accounts to make them recommendable
|
|
follower_accounts.each do |follower_account|
|
|
target_accounts.each do |target_account|
|
|
Fabricate(:follow, account: follower_account, target_account: target_account)
|
|
end
|
|
end
|
|
end
|
|
|
|
it 'creates recommendations' do
|
|
expect { scheduled_run }.to change(FollowRecommendation, :count).from(0).to(target_accounts.size)
|
|
end
|
|
end
|
|
|
|
context 'when there are no accounts to recommend' do
|
|
it 'does not create follow recommendations' do
|
|
expect { scheduled_run }.to_not change(FollowRecommendation, :count)
|
|
end
|
|
end
|
|
end
|
|
end
|