Add subscribable_project to ToggleSubscriptionAction concern

parent 9a2157a6
...@@ -4,13 +4,17 @@ module ToggleSubscriptionAction ...@@ -4,13 +4,17 @@ module ToggleSubscriptionAction
def toggle_subscription def toggle_subscription
return unless current_user return unless current_user
subscribable_resource.toggle_subscription(current_user) subscribable_resource.toggle_subscription(current_user, subscribable_project)
head :ok head :ok
end end
private private
def subscribable_project
raise NotImplementedError
end
def subscribable_resource def subscribable_resource
raise NotImplementedError raise NotImplementedError
end end
......
...@@ -169,6 +169,10 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -169,6 +169,10 @@ class Projects::IssuesController < Projects::ApplicationController
alias_method :awardable, :issue alias_method :awardable, :issue
alias_method :spammable, :issue alias_method :spammable, :issue
def subscribable_project
issue.project
end
def authorize_read_issue! def authorize_read_issue!
return render_404 unless can?(current_user, :read_issue, @issue) return render_404 unless can?(current_user, :read_issue, @issue)
end end
......
...@@ -125,6 +125,10 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -125,6 +125,10 @@ class Projects::LabelsController < Projects::ApplicationController
end end
alias_method :subscribable_resource, :label alias_method :subscribable_resource, :label
def subscribable_project
@project
end
def find_labels def find_labels
@available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
end end
......
...@@ -473,6 +473,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -473,6 +473,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
alias_method :issuable, :merge_request alias_method :issuable, :merge_request
alias_method :awardable, :merge_request alias_method :awardable, :merge_request
def subscribable_project
merge_request.project
end
def authorize_update_merge_request! def authorize_update_merge_request!
return render_404 unless can?(current_user, :update_merge_request, @merge_request) return render_404 unless can?(current_user, :update_merge_request, @merge_request)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment