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

remove parameters from methods used as before actions

ulferts683bb65dbdd9
diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rb
index fd5620b6f76..8000d6ac766 100644
--- a/app/controllers/concerns/accounts/authorization.rb
+++ b/app/controllers/concerns/accounts/authorization.rb
@@ -65,15 +65,14 @@ module Accounts::Authorization
# Authorize the user for the requested controller action.
# To be used in before_action hooks
- def authorize(ctrl = params[:controller], action = params[:action])
- do_authorize({ controller: ctrl, action: }, global: false)
+ def authorize
+ do_authorize({ controller: params[:controller], action: params[:action] }, global: false)
end
# Authorize the user for the requested controller action outside a project
# To be used in before_action hooks
def authorize_global
- action = { controller: params[:controller], action: params[:action] }
- do_authorize(action, global: true)
+ do_authorize({ controller: params[:controller], action: params[:action] }, global: true)
end
# Find a project based on params[:project_id]
diff --git a/spec/support/permission_specs.rb b/spec/support/permission_specs.rb
index 389e356dbe9..caf21413d0a 100644
--- a/spec/support/permission_specs.rb
+++ b/spec/support/permission_specs.rb
@@ -52,15 +52,19 @@ module PermissionSpecs
controller_name, action_name = controller_action.split("#")
it "allows calling #{controller_action} when having the permission #{permission}" do
+ controller.params = { controller: controller_name, action: action_name }
+
become_member_with_permissions(project, current_user, permission)
- expect(controller.send(:authorize, controller_name, action_name)).to be_truthy
+ expect(controller.send(:authorize)).to be_truthy
end
it "prevents calling #{controller_action} when not having the permission #{permission}" do
+ controller.params = { controller: controller_name, action: action_name }
+
become_member(project, current_user)
- expect(controller.send(:authorize, controller_name, action_name)).to be_falsey
+ expect(controller.send(:authorize)).to be_falsey
end
end