diff options
author | Rémy Coutable <remy@rymai.me> | 2016-03-15 19:18:47 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-15 20:22:03 +0300 |
commit | c98089b2b29bbcb44cdce7ce23bff3fa5d10d3f3 (patch) | |
tree | c0a0a38d023e8b95e9a4cae172dd876d881c68be /app/controllers/projects/labels_controller.rb | |
parent | 54ec7e959900493b6e9174bf4dfe09ed0afd1e46 (diff) |
Move the #toggle_subscription controller method to a concern
Diffstat (limited to 'app/controllers/projects/labels_controller.rb')
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index e4dea6b065a..40d8098690a 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,8 +1,12 @@ class Projects::LabelsController < Projects::ApplicationController + include ToggleSubscriptionAction + before_action :module_enabled - before_action :label, only: [:edit, :update, :destroy, :toggle_subscription] + before_action :label, only: [:edit, :update, :destroy] before_action :authorize_read_label! - before_action :authorize_admin_labels!, except: [:index, :toggle_subscription] + before_action :authorize_admin_labels!, only: [ + :new, :create, :edit, :update, :generate, :destroy + ] respond_to :js, :html @@ -60,13 +64,6 @@ class Projects::LabelsController < Projects::ApplicationController end end - def toggle_subscription - return unless current_user - - @label.toggle_subscription(current_user) - render nothing: true - end - protected def module_enabled @@ -80,8 +77,9 @@ class Projects::LabelsController < Projects::ApplicationController end def label - @label = @project.labels.find(params[:id]) + @label ||= @project.labels.find(params[:id]) end + alias_method :subscribable_resource, :label def authorize_admin_labels! return render_404 unless can?(current_user, :admin_label, @project) |