From aa9a6b38f295c76a6b496942b70a3a7c24a20c83 Mon Sep 17 00:00:00 2001 From: NewAlexandria Date: Sun, 3 Mar 2024 17:39:47 -0500 Subject: [PATCH] test for staging env acceptability --- .gitignore | 2 ++ app/controllers/rake_ui/application_controller.rb | 5 ++++- lib/rake-ui.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4bbb9ed..75af97e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /test/dummy/tmp/development_secret.txt .byebug_history + +.DS_Store diff --git a/app/controllers/rake_ui/application_controller.rb b/app/controllers/rake_ui/application_controller.rb index 0b6bf4a..f77b435 100644 --- a/app/controllers/rake_ui/application_controller.rb +++ b/app/controllers/rake_ui/application_controller.rb @@ -11,6 +11,9 @@ class ApplicationController < ActionController::Base # before_action :authorize_pundit # before_action :authorize! + STAGING_OK = (Rails.env.staging? && RakeUi.configuration.allow_staging) + PROD_OK = RakeUi.configuration.allow_production + private def authorize_pundit @@ -22,7 +25,7 @@ def authorize_pundit end def black_hole_production - return if Rails.env.test? || Rails.env.development? || RakeUi.configuration.allow_production + return if Rails.env.test? || Rails.env.development? || STAGING_OK || PROD_OK raise ActionController::RoutingError, "Not Found" end diff --git a/lib/rake-ui.rb b/lib/rake-ui.rb index 447398d..475f016 100644 --- a/lib/rake-ui.rb +++ b/lib/rake-ui.rb @@ -4,12 +4,14 @@ module RakeUi mattr_accessor :allow_production + mattr_accessor :allow_staging mattr_accessor :policy_engine mattr_accessor :policy_callback mattr_accessor :auth_engine mattr_accessor :auth_callback self.allow_production = false + self.allow_staging = true self.policy_engine = nil self.policy_callback = nil self.auth_engine = nil