diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-31 17:21:13 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-11-15 16:08:21 -0200 |
commit | 6352a76c608ff7aa2ec628a40cba6cd39968a4fe (patch) | |
tree | 7088432d71691a5fc6c72e0e779cad48ba6ca70b | |
parent | 2570029c8fd616bb56c258f4a93d91cfcbf4f66c (diff) | |
download | gitlab-ce-6352a76c608ff7aa2ec628a40cba6cd39968a4fe.tar.gz |
Add subscribable_project to ToggleSubscriptionAction concern
4 files changed, 17 insertions, 1 deletions
diff --git a/app/controllers/concerns/toggle_subscription_action.rb b/app/controllers/concerns/toggle_subscription_action.rb index 9e3b9be2ff4..3be89dc5024 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 3f1a1d1c511..460a8ae6395 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 42fd09e9b7e..93cfd8a7721 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 dff0213411c..0eda3c3c80c 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 |