Fix Lint/AmbiguousBlockAssociation cop (#25921)

This commit is contained in:
Matt Jankowski 2023-07-12 04:02:41 -04:00 committed by GitHub
parent b786911c55
commit 658742b3cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 15 deletions

View file

@ -48,15 +48,6 @@ Layout/SpaceInLambdaLiteral:
- 'config/environments/production.rb' - 'config/environments/production.rb'
- 'config/initializers/content_security_policy.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. # Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock: Lint/EmptyBlock:
Exclude: Exclude:

View file

@ -104,7 +104,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
post :create, post :create,
params: { form_two_factor_confirmation: { otp_attempt: '123456' } }, params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' } 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 end
it 'renders the new view' do it 'renders the new view' do

View file

@ -63,7 +63,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
expect do expect do
post :create, session: { challenge_passed_at: Time.now.utc } post :create, session: { challenge_passed_at: Time.now.utc }
end.to not_change { user.reload.otp_secret } 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) expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path)
end end
@ -80,7 +80,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
expect do expect do
post :create, session: { challenge_passed_at: Time.now.utc } post :create, session: { challenge_passed_at: Time.now.utc }
end.to not_change { user.reload.otp_secret } 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) expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path)
end end

View file

@ -214,11 +214,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end end
it 'does not create any edits' do 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 end
it 'does not update the text, spoiler_text or edited_at' do 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
end end

View file

@ -52,7 +52,7 @@ RSpec.describe PostStatusService, type: :service do
end end
it 'does not change statuses count' do 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
end end