From 28d554cc49b77e2fc0c0676f8ee857a5a761301f Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 26 Apr 2023 11:25:07 -0400 Subject: [PATCH] Autofix Rubocop Rails/ResponseParsedBody (#24051) --- .rubocop_todo.yml | 9 --------- spec/controllers/follower_accounts_controller_spec.rb | 2 +- spec/controllers/following_accounts_controller_spec.rb | 2 +- .../webauthn_credentials_controller_spec.rb | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2e9de6b8d5..4b08155e0d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1489,15 +1489,6 @@ Rails/RakeEnvironment: - 'lib/tasks/repo.rake' - 'lib/tasks/statistics.rake' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb -Rails/ResponseParsedBody: - Exclude: - - 'spec/controllers/follower_accounts_controller_spec.rb' - - 'spec/controllers/following_accounts_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - # Configuration parameters: Include. # Include: db/**/*.rb Rails/ReversibleMigration: diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index 7c53e5b472..0551dfcdec 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -41,7 +41,7 @@ describe FollowerAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } - subject(:body) { JSON.parse(response.body) } + subject(:body) { response.parsed_body } context 'with page' do let(:page) { 1 } diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index 122f72e2d0..b049df890f 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -41,7 +41,7 @@ describe FollowingAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } - subject(:body) { JSON.parse(response.body) } + subject(:body) { response.parsed_body } context 'with page' do let(:page) { 1 } diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index a95521c94a..719f70f16b 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -140,7 +140,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do it 'includes existing credentials in list of excluded credentials' do get :options - excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].pluck('id') + excluded_credentials_ids = response.parsed_body['excludeCredentials'].pluck('id') expect(excluded_credentials_ids).to match_array(user.webauthn_credentials.pluck(:external_id)) end end