Skip to content

Commit

Permalink
Use new permission in schedule controller
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Dec 19, 2024
1 parent b3b4fac commit 5e5fa5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/accounts/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/concerns/authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -142,7 +142,7 @@ def test
render plain: "OK"
end

def do_authorize(_permission, global: true)
def do_authorize(*)
true
end
end
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -209,7 +209,7 @@ def test
render plain: "OK"
end

def do_authorize(_permission, global: true)
def do_authorize(*)
true
end
end
Expand Down

0 comments on commit 5e5fa5f

Please sign in to comment.