mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 00:30:57 +01:00
Fix followers count not being updated when migrating follows (#19998)
Fixes #19900
This commit is contained in:
parent
a70e2cd649
commit
5925a31b78
2 changed files with 18 additions and 1 deletions
|
@ -8,7 +8,9 @@ class MoveWorker
|
||||||
@target_account = Account.find(target_account_id)
|
@target_account = Account.find(target_account_id)
|
||||||
|
|
||||||
if @target_account.local? && @source_account.local?
|
if @target_account.local? && @source_account.local?
|
||||||
rewrite_follows!
|
nb_moved = rewrite_follows!
|
||||||
|
@source_account.update_count!(:followers_count, -nb_moved)
|
||||||
|
@target_account.update_count!(:followers_count, nb_moved)
|
||||||
else
|
else
|
||||||
queue_follow_unfollows!
|
queue_follow_unfollows!
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,18 @@ describe MoveWorker do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples 'followers count handling' do
|
||||||
|
it 'updates the source account followers count' do
|
||||||
|
subject.perform(source_account.id, target_account.id)
|
||||||
|
expect(source_account.reload.followers_count).to eq(source_account.passive_relationships.count)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'updates the target account followers count' do
|
||||||
|
subject.perform(source_account.id, target_account.id)
|
||||||
|
expect(target_account.reload.followers_count).to eq(target_account.passive_relationships.count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'both accounts are distant' do
|
context 'both accounts are distant' do
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
it 'calls UnfollowFollowWorker' do
|
it 'calls UnfollowFollowWorker' do
|
||||||
|
@ -83,6 +95,7 @@ describe MoveWorker do
|
||||||
|
|
||||||
include_examples 'user note handling'
|
include_examples 'user note handling'
|
||||||
include_examples 'block and mute handling'
|
include_examples 'block and mute handling'
|
||||||
|
include_examples 'followers count handling'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -97,6 +110,7 @@ describe MoveWorker do
|
||||||
|
|
||||||
include_examples 'user note handling'
|
include_examples 'user note handling'
|
||||||
include_examples 'block and mute handling'
|
include_examples 'block and mute handling'
|
||||||
|
include_examples 'followers count handling'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -112,6 +126,7 @@ describe MoveWorker do
|
||||||
|
|
||||||
include_examples 'user note handling'
|
include_examples 'user note handling'
|
||||||
include_examples 'block and mute handling'
|
include_examples 'block and mute handling'
|
||||||
|
include_examples 'followers count handling'
|
||||||
|
|
||||||
it 'does not fail when a local user is already following both accounts' do
|
it 'does not fail when a local user is already following both accounts' do
|
||||||
double_follower = Fabricate(:account)
|
double_follower = Fabricate(:account)
|
||||||
|
|
Loading…
Reference in a new issue