From 7f842d77ea9573cca63f8bdd1ed5b906fed09655 Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Wed, 14 May 2025 11:08:43 +0200 Subject: [PATCH] Fixes RSpec Rails HaveHttpStatus cop in services & support --- .rubocop_todo.yml | 9 --------- spec/services/embedded_page_service_spec.rb | 2 +- spec/support/api_helper.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dbbfceadd3..21827aeb4d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -221,15 +221,6 @@ Metrics/PerceivedComplexity: - 'app/models/spree/ability.rb' - 'app/models/spree/order/checkout.rb' -# Offense count: 28 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ResponseMethods. -# ResponseMethods: response, last_response -RSpecRails/HaveHttpStatus: - Exclude: - - 'spec/services/embedded_page_service_spec.rb' - - 'spec/support/api_helper.rb' - # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/services/embedded_page_service_spec.rb b/spec/services/embedded_page_service_spec.rb index 4ae9f91ba4..11f242c515 100644 --- a/spec/services/embedded_page_service_spec.rb +++ b/spec/services/embedded_page_service_spec.rb @@ -84,7 +84,7 @@ RSpec.describe EmbeddedPageService do end it "returns a 200 status" do - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end end diff --git a/spec/support/api_helper.rb b/spec/support/api_helper.rb index ee632d16de..c41a7cfd81 100644 --- a/spec/support/api_helper.rb +++ b/spec/support/api_helper.rb @@ -24,7 +24,7 @@ module OpenFoodNetwork def assert_unauthorized! expect(json_response).to eq("error" => "You are not authorized to perform that action.") - expect(response.status).to eq 401 + expect(response).to have_http_status :unauthorized end end end