diff options
author | Nick Thomas <nick@gitlab.com> | 2017-06-20 11:59:50 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-06-21 10:56:45 +0100 |
commit | 03228cb5b659ab6c9b631bafdf21ba77d6d2d2fa (patch) | |
tree | 681aecfa9824d9261fde8459d031cc23f22e0592 | |
parent | 4b0b2f1525be5feac0ae0953eb573ff24cc7b9c5 (diff) | |
download | gitlab-ce-03228cb5b659ab6c9b631bafdf21ba77d6d2d2fa.tar.gz |
Backport check_project_feature_available! from EE
-rw-r--r-- | app/controllers/projects/application_controller.rb | 9 |
1 files changed, 8 insertions, 1 deletions
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 |