From c0808a89df541b0996276a379b0ed696d111c202 Mon Sep 17 00:00:00 2001 From: Diego Basterrech Date: Tue, 14 Jan 2025 14:19:41 -0300 Subject: [PATCH] Add flag to cossider system request not local --- app/controllers/kiosk_reservations_controller.rb | 6 +----- config/environments/test.rb | 2 +- spec/rails_helper.rb | 9 +++++++++ spec/system/kiosk_view_spec.rb | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/controllers/kiosk_reservations_controller.rb b/app/controllers/kiosk_reservations_controller.rb index 16d9306b36..ce0c4028bc 100644 --- a/app/controllers/kiosk_reservations_controller.rb +++ b/app/controllers/kiosk_reservations_controller.rb @@ -102,11 +102,7 @@ def respond_error(message) def check_kiosk_enabled return if current_facility&.kiosk_enabled? && SettingsHelper.feature_on?(:kiosk_view) - if current_user - render "errors/forbidden", status: :forbidden - else - return redirect_to new_user_session_path, alert: "You need to login to access this page." - end + raise NUCore::PermissionDenied end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 7ee231e145..c2482b25b8 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -31,7 +31,7 @@ config.active_record.migration_error = :page_load # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 23c5a23b55..53b8f936ad 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -230,6 +230,15 @@ def facilities_route Warden.test_reset! end + config.around(:each, :disable_requests_local) do |example| + Rails.application.config.tap do |app_config| + prev_val = app_config.consider_all_requests_local + app_config.consider_all_requests_local = false + example.run + app_config.consider_all_requests_local = prev_val + end + end + require "rspec/active_job" config.include(RSpec::ActiveJob) end diff --git a/spec/system/kiosk_view_spec.rb b/spec/system/kiosk_view_spec.rb index 06918b07dd..603b4f96d7 100644 --- a/spec/system/kiosk_view_spec.rb +++ b/spec/system/kiosk_view_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe "Launching Kiosk View", :js, feature_setting: { kiosk_view: true, bypass_kiosk_auth: false } do +RSpec.describe "Launching Kiosk View", :js, :disable_requests_local, feature_setting: { kiosk_view: true, bypass_kiosk_auth: false } do let(:facility) { create(:setup_facility, kiosk_enabled: true) } let(:account) { create(:setup_account) } let!(:account_user) { FactoryBot.create(:account_user, :purchaser, account: account, user: user) }