From 60a429e4639a6b9c2c111163c7f63a03455f4c96 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Oct 2025 13:33:34 +0100 Subject: [PATCH] Use more naturally-sounding ensures These match Basecamp and the existing predicate methods --- app/controllers/admin_controller.rb | 2 +- app/controllers/concerns/authorization.rb | 4 ++-- app/controllers/webhooks/activations_controller.rb | 2 +- app/controllers/webhooks_controller.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 4e7e52372..cc268a567 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,3 @@ class AdminController < ApplicationController - before_action :ensure_is_staff_member + before_action :ensure_staff end diff --git a/app/controllers/concerns/authorization.rb b/app/controllers/concerns/authorization.rb index 38873b098..9744a0465 100644 --- a/app/controllers/concerns/authorization.rb +++ b/app/controllers/concerns/authorization.rb @@ -1,10 +1,10 @@ module Authorization private - def ensure_can_administer + def ensure_admin head :forbidden unless Current.user.admin? end - def ensure_is_staff_member + def ensure_staff head :forbidden unless Current.user.staff? end end diff --git a/app/controllers/webhooks/activations_controller.rb b/app/controllers/webhooks/activations_controller.rb index ea30e1e87..e99cd35b4 100644 --- a/app/controllers/webhooks/activations_controller.rb +++ b/app/controllers/webhooks/activations_controller.rb @@ -1,5 +1,5 @@ class Webhooks::ActivationsController < ApplicationController - before_action :ensure_can_administer + before_action :ensure_admin before_action :set_webhook def create diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 8f8315186..41f9edffb 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -1,5 +1,5 @@ class WebhooksController < ApplicationController - before_action :ensure_can_administer + before_action :ensure_admin before_action :set_collection before_action :set_webhook, except: %i[ index new create ]