diff --git a/app/controllers/concerns/toggle_subscription_action.rb b/app/controllers/concerns/toggle_subscription_action.rb index 9e3b9be2ff40869d9c5dbc5f2a0296153e00a91e..3be89dc5024a8e1b15dd88359bcdeafb4529e21b 100644 --- a/app/controllers/concerns/toggle_subscription_action.rb +++ b/app/controllers/concerns/toggle_subscription_action.rb @@ -4,13 +4,17 @@ module ToggleSubscriptionAction def toggle_subscription return unless current_user - subscribable_resource.toggle_subscription(current_user) + subscribable_resource.toggle_subscription(current_user, subscribable_project) head :ok end private + def subscribable_project + raise NotImplementedError + end + def subscribable_resource raise NotImplementedError end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 3f1a1d1c51167c0181a0f099f329b909bb37bd02..460a8ae639516fda9de6850d0242af9b02c958a5 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -169,6 +169,10 @@ class Projects::IssuesController < Projects::ApplicationController alias_method :awardable, :issue alias_method :spammable, :issue + def subscribable_project + issue.project + end + def authorize_read_issue! return render_404 unless can?(current_user, :read_issue, @issue) end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 42fd09e9b7e0250d96e202b51ec9d22f2987f720..93cfd8a7721aaac3564f069b38e6291d6627e1b2 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -125,6 +125,10 @@ class Projects::LabelsController < Projects::ApplicationController end alias_method :subscribable_resource, :label + def subscribable_project + @project + end + def find_labels @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index dff0213411c440e58933be7bbbd8944aad052f31..0eda3c3c80cb282a7521909eff4388bf6a080bf0 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -473,6 +473,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController alias_method :issuable, :merge_request alias_method :awardable, :merge_request + def subscribable_project + merge_request.project + end + def authorize_update_merge_request! return render_404 unless can?(current_user, :update_merge_request, @merge_request) end