From 03228cb5b659ab6c9b631bafdf21ba77d6d2d2fa Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 20 Jun 2017 11:59:50 +0100 Subject: Backport check_project_feature_available! from EE --- app/controllers/projects/application_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 603a51266da..d085a566527 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -53,9 +53,16 @@ class Projects::ApplicationController < ApplicationController end end + def check_project_feature_available!(feature) + return render_404 unless project.feature_available?(feature, current_user) + end + def method_missing(method_sym, *arguments, &block) - if method_sym.to_s =~ /\Aauthorize_(.*)!\z/ + case method_sym.to_s + when /\Aauthorize_(.*)!\z/ authorize_action!($1.to_sym) + when /\Acheck_(.*)_available!\z/ + check_project_feature_available!($1.to_sym) else super end -- cgit v1.2.1