Skip to content

Commit

Permalink
Add flag to cossider system request not local
Browse files Browse the repository at this point in the history
  • Loading branch information
diebas committed Jan 14, 2025
1 parent e187367 commit c0808a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/controllers/kiosk_reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/system/kiosk_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit c0808a8

Please sign in to comment.