Add delay to profile updates to debounce them (#34137)

This commit is contained in:
Claire 2025-03-11 17:17:17 +01:00 committed by GitHub
parent 725a68d273
commit 420ffdfb62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 17 additions and 23 deletions

View file

@ -11,8 +11,6 @@ RSpec.describe 'Settings Privacy' do
before { user.account.update(discoverable: false) }
context 'with a successful update' do
before { allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async) }
it 'updates user profile information' do
# View settings page
visit settings_privacy_path
@ -29,14 +27,13 @@ RSpec.describe 'Settings Privacy' do
.to have_content(I18n.t('privacy.title'))
.and have_content(success_message)
expect(ActivityPub::UpdateDistributionWorker)
.to have_received(:perform_async).with(user.account.id)
.to have_enqueued_sidekiq_job(user.account.id)
end
end
context 'with a failed update' do
before do
allow(UpdateAccountService).to receive(:new).and_return(failing_update_service)
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
end
it 'updates user profile information' do
@ -54,7 +51,7 @@ RSpec.describe 'Settings Privacy' do
expect(page)
.to have_content(I18n.t('privacy.title'))
expect(ActivityPub::UpdateDistributionWorker)
.to_not have_received(:perform_async)
.to_not have_enqueued_sidekiq_job(anything)
end
private

View file

@ -7,7 +7,6 @@ RSpec.describe 'Settings profile page' do
let(:account) { user.account }
before do
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
sign_in user
end
@ -24,7 +23,7 @@ RSpec.describe 'Settings profile page' do
.to change { account.reload.display_name }.to('New name')
.and(change { account.reload.avatar.instance.avatar_file_name }.from(nil).to(be_present))
expect(ActivityPub::UpdateDistributionWorker)
.to have_received(:perform_async).with(account.id)
.to have_enqueued_sidekiq_job(account.id)
end
def display_name_field