Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

raise error in every env

ulferts36b4e47d36a0
diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rb
index afcc1f302f6..206e81e78c4 100644
--- a/app/controllers/concerns/accounts/authorization.rb
+++ b/app/controllers/concerns/accounts/authorization.rb
@@ -47,19 +47,15 @@ module Accounts::Authorization
def authorization_check_required
unless authorization_is_ensured?(params[:action])
- if Rails.env.development?
- raise <<-MESSAGE
- Authorization check required for #{params[:action]} in #{self.class.name}.
-
- Use any method of
- #{METHODS_ENFORCING_AUTHORIZATION.join(', ')}
- to ensure authorization. If authorization is checked by any other means,
- affirm the same by calling 'authorization_checked!' in the controller. If the authorization does
- not need to be checked for this action, affirm the same by calling 'no_authorization_required!'
- MESSAGE
- else
- render_403
- end
+ raise <<-MESSAGE
+ Authorization check required for #{self.class.name}##{params[:action]}.
+
+ Use any method of
+ #{METHODS_ENFORCING_AUTHORIZATION.join(', ')}
+ to ensure authorization. If authorization is checked by any other means,
+ affirm the same by calling 'authorization_checked!' in the controller. If the authorization does
+ not need to be checked for this action, affirm the same by calling 'no_authorization_required!'
+ MESSAGE
end
end
diff --git a/spec/controllers/concerns/authorization_spec.rb b/spec/controllers/concerns/authorization_spec.rb
index de0e0fee0ae..ac9dbd42f89 100644
--- a/spec/controllers/concerns/authorization_spec.rb
+++ b/spec/controllers/concerns/authorization_spec.rb
@@ -64,11 +64,9 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
end
shared_examples "is prevented" do
- it "fails with a 403" do
- get :index
-
- expect(response)
- .to have_http_status :forbidden
+ it "fails with a RuntimeError" do
+ expect { get :index }
+ .to raise_error RuntimeError
end
end