diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-03-16 17:20:17 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-03-16 21:38:41 +0200 |
commit | 1b437ec3498bc544dbd1b252f5c755e9073407fd (patch) | |
tree | e3c0cea66260a2b65d21b660ebd4b042a6b0c80c /app/controllers | |
parent | f53683e67fa0db7b13d0dee977bc21206af7e0fd (diff) | |
download | gitlab-ce-1b437ec3498bc544dbd1b252f5c755e9073407fd.tar.gz |
tests
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 9 |
2 files changed, 6 insertions, 12 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 903b7a68dc9..88302276b5e 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -1,6 +1,6 @@ class Projects::IssuesController < Projects::ApplicationController before_filter :module_enabled - before_filter :issue, only: [:edit, :update, :show, :set_subscription] + before_filter :issue, only: [:edit, :update, :show, :toggle_subscription] # Allow read any issue before_filter :authorize_read_issue! @@ -97,11 +97,8 @@ class Projects::IssuesController < Projects::ApplicationController redirect_to :back, notice: "#{result[:count]} issues updated" end - def set_subscription - subscribed = params[:subscription] == "Subscribe" - - sub = @issue.subscriptions.find_or_create_by(user_id: current_user.id) - sub.update(subscribed: subscribed) + def toggle_subscription + @issue.toggle_subscription(current_user) render nothing: true end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 51ac61c3273..c63a9b0cd44 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -2,7 +2,7 @@ require 'gitlab/satellite/satellite' class Projects::MergeRequestsController < Projects::ApplicationController before_filter :module_enabled - before_filter :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :set_subscription] + before_filter :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :toggle_subscription] before_filter :closes_issues, only: [:edit, :update, :show, :diffs] before_filter :validates_merge_request, only: [:show, :diffs] before_filter :define_show_vars, only: [:show, :diffs] @@ -174,11 +174,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController render json: response end - def set_subscription - subscribed = params[:subscription] == "Subscribe" - - sub = @merge_request.subscriptions.find_or_create_by(user_id: current_user.id) - sub.update(subscribed: subscribed) + def toggle_subscription + @merge_request.toggle_subscription(current_user) render nothing: true end |