From 48c14b8a390281d61f3318a1518adbf83c68adda Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Mon, 7 Nov 2022 15:59:48 +0200 Subject: [PATCH] fixed tests --- app/controllers/epp/base_controller.rb | 2 +- app/controllers/repp/v1/base_controller.rb | 2 +- app/lib/shunter/integration/throttle.rb | 2 +- test/models/epp/response/result/code_test.rb | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index a481a8f9a..1f1de8458 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -34,7 +34,7 @@ module Epp code: '2502', msg: Shunter.default_error_message) handle_errors - log_exception(exception) + log_exception(exception) unless Rails.env.test? end def respond_with_command_failed_error(exception) diff --git a/app/controllers/repp/v1/base_controller.rb b/app/controllers/repp/v1/base_controller.rb index 903c9e58b..2b05df8ef 100644 --- a/app/controllers/repp/v1/base_controller.rb +++ b/app/controllers/repp/v1/base_controller.rb @@ -29,7 +29,7 @@ module Repp render(json: @response, status: :unauthorized) rescue Shunter::ThrottleError => e @response = { code: 2502, message: Shunter.default_error_message } - logger.error e.to_s + logger.error e.to_s unless Rails.env.test? render(json: @response, status: :bad_request) ensure create_repp_log diff --git a/app/lib/shunter/integration/throttle.rb b/app/lib/shunter/integration/throttle.rb index 91fb033ac..39d83ad76 100644 --- a/app/lib/shunter/integration/throttle.rb +++ b/app/lib/shunter/integration/throttle.rb @@ -26,7 +26,7 @@ module Shunter logger.info "Request from #{throttled_user.class}/#{throttled_user.id} is coming through throttling" yield if block_given? else - logger.info "Too many requests from #{throttled_user.class}/#{throttled_user.id}." + logger.info "Too many requests from #{throttled_user.class}/#{throttled_user.id}." unless Rails.env.test? raise Shunter::ThrottleError end end diff --git a/test/models/epp/response/result/code_test.rb b/test/models/epp/response/result/code_test.rb index ca41db458..dfc1871f5 100644 --- a/test/models/epp/response/result/code_test.rb +++ b/test/models/epp/response/result/code_test.rb @@ -58,6 +58,8 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase end def test_returns_default_descriptions + ENV["shunter_default_threshold"] = '100' + descriptions = { 1000 => 'Command completed successfully', 1001 => 'Command completed successfully; action pending', @@ -88,6 +90,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase 2502 => Shunter.default_error_message } assert_equal descriptions, Epp::Response::Result::Code.default_descriptions + ENV["shunter_default_threshold"] = '10000' end def test_equality