From b229fa7916c934a79430f066f2bf21c095bfb31c Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 12 Jul 2023 04:02:41 -0400 Subject: [PATCH] Fix `Lint/AmbiguousBlockAssociation` cop (#25921) --- .rubocop_todo.yml | 9 --------- .../confirmations_controller_spec.rb | 2 +- .../otp_authentication_controller_spec.rb | 4 ++-- .../activitypub/process_status_update_service_spec.rb | 4 ++-- spec/services/post_status_service_spec.rb | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d950c2f571..0aaae67fb5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -48,15 +48,6 @@ Layout/SpaceInLambdaLiteral: - 'config/environments/production.rb' - 'config/initializers/content_security_policy.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods, AllowedPatterns. -Lint/AmbiguousBlockAssociation: - Exclude: - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/post_status_service_spec.rb' - # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Exclude: diff --git a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb index 84dfd60b38..37381fe1f7 100644 --- a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb @@ -104,7 +104,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' } - end.to not_change { user.reload.otp_secret } + end.to(not_change { user.reload.otp_secret }) end it 'renders the new view' do diff --git a/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb index c8ba6f9a88..007df87d95 100644 --- a/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb @@ -63,7 +63,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do expect do post :create, session: { challenge_passed_at: Time.now.utc } end.to not_change { user.reload.otp_secret } - .and change { session[:new_otp_secret] } + .and(change { session[:new_otp_secret] }) expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path) end @@ -80,7 +80,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do expect do post :create, session: { challenge_passed_at: Time.now.utc } end.to not_change { user.reload.otp_secret } - .and change { session[:new_otp_secret] } + .and(change { session[:new_otp_secret] }) expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path) end diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 9d90e5eb80..f7bcfaf7fb 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -214,11 +214,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'does not create any edits' do - expect { subject.call(status, json) }.to_not change { status.reload.edits.pluck(&:id) } + expect { subject.call(status, json) }.to_not(change { status.reload.edits.pluck(&:id) }) end it 'does not update the text, spoiler_text or edited_at' do - expect { subject.call(status, json) }.to_not change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] } + expect { subject.call(status, json) }.to_not(change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] }) end end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index d201292e17..7d7679c889 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -52,7 +52,7 @@ RSpec.describe PostStatusService, type: :service do end it 'does not change statuses count' do - expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not change { [account.statuses_count, previous_status.replies_count] } + expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not(change { [account.statuses_count, previous_status.replies_count] }) end end