From 5e5fa5f37e6eb6a7edc3fe4235e9b4b628a9aba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 19 Dec 2024 11:11:52 +0100 Subject: [PATCH] Use new permission in schedule controller --- app/controllers/concerns/accounts/authorization.rb | 2 +- .../controllers/recurring_meetings/schedule_controller.rb | 5 +---- spec/controllers/concerns/authorization_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rb index a45f130a49dd..93320f71eb19 100644 --- a/app/controllers/concerns/accounts/authorization.rb +++ b/app/controllers/concerns/accounts/authorization.rb @@ -85,7 +85,7 @@ def load_and_authorize_in_optional_project # Action can be: # * a parameter-like Hash (eg. { controller: '/projects', action: 'edit' }) # * a permission Symbol (eg. :edit_project) - def do_authorize(action, global: false) + def do_authorize(action, global: false) # rubocop:disable Metrics/PerceivedComplexity is_authorized = if global User.current.allowed_based_on_permission_context?(action) else diff --git a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb index 8c8b842494c3..d85ad73a1e64 100644 --- a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb +++ b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb @@ -1,9 +1,6 @@ module RecurringMeetings class ScheduleController < ApplicationController - before_action do - do_authorize :create_meetings, global: true - end - authorization_checked! :humanize_schedule + authorize_with_permission :create_meetings, global: true around_action :with_user_time_zone before_action :build_meeting diff --git a/spec/controllers/concerns/authorization_spec.rb b/spec/controllers/concerns/authorization_spec.rb index dcf42dde8983..60e4aa61807a 100644 --- a/spec/controllers/concerns/authorization_spec.rb +++ b/spec/controllers/concerns/authorization_spec.rb @@ -115,7 +115,7 @@ def other_before_action; end authorize_with_permission :view_project - def do_authorize(_permission, global: false) + def do_authorize(*) true end end @@ -142,7 +142,7 @@ def test render plain: "OK" end - def do_authorize(_permission, global: true) + def do_authorize(*) true end end @@ -172,7 +172,7 @@ def do_authorize(_permission, global: true) load_and_authorize_with_permission_in_optional_project :view_project - def do_authorize(_permission, global: true) + def do_authorize(*) true end end @@ -209,7 +209,7 @@ def test render plain: "OK" end - def do_authorize(_permission, global: true) + def do_authorize(*) true end end