Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-09 10:50:18 +0300
committerPhil Hughes <me@iamphill.com>2016-06-14 10:36:07 +0300
commit330e91368195e182cbfa9b41a1d5304f67d07334 (patch)
treede53a6907df8a965929f513ca5e54bcb7d97ffc0 /app/controllers/projects/todos_controller.rb
parent20d382a891d92197620eb4e72526577a916292d7 (diff)
Uses update URL to update the status of a todo
Diffstat (limited to 'app/controllers/projects/todos_controller.rb')
-rw-r--r--app/controllers/projects/todos_controller.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/controllers/projects/todos_controller.rb b/app/controllers/projects/todos_controller.rb
index 21745977860..64e70a5bcc6 100644
--- a/app/controllers/projects/todos_controller.rb
+++ b/app/controllers/projects/todos_controller.rb
@@ -1,20 +1,23 @@
class Projects::TodosController < Projects::ApplicationController
def create
- json_data = Hash.new
+ TodoService.new.mark_todo(issuable, current_user)
- if params[:todo_id].nil?
- TodoService.new.mark_todo(issuable, current_user)
+ render json: {
+ todo: current_user.todos.find_by(state: :pending, action: Todo::MARKED, target_id: issuable.id),
+ count: current_user.todos.pending.count,
+ }
+ end
- json_data[:todo] = current_user.todos.find_by(state: :pending, action: Todo::MARKED, target_id: issuable.id)
- else
- current_user.todos.find_by_id(params[:todo_id]).update(state: :done)
- end
+ def update
+ current_user.todos.find_by_id(params[:id]).update(state: :done)
- render json: json_data.merge({ count: current_user.todos.pending.count })
+ render json: {
+ count: current_user.todos.pending.count,
+ }
end
private
-
+
def issuable
@issuable ||= begin
case params[:issuable_type]