summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-08-16 22:10:37 +0200
committerAhmad Sherif <me@ahmadsherif.com>2016-08-18 17:46:24 +0200
commit548da42be51821951180eacf462d942c11c0c01b (patch)
tree56d3335fe86ae4c4a2dfc26951d241c8d762d34e /app
parent30654fc9c1afc222ebae5c5367657bd8f6e615b2 (diff)
downloadgitlab-ce-548da42be51821951180eacf462d942c11c0c01b.tar.gz
Implement TodoService#mark_todos_as_done_by_id
Follow-up on 52b0c26
Diffstat (limited to 'app')
-rw-r--r--app/controllers/dashboard/todos_controller.rb4
-rw-r--r--app/services/todo_service.rb6
2 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index 1f8cf1d91b0..32f5c09eac1 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -6,9 +6,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end
def destroy
- todo = Todo.new(id: params[:id])
-
- TodoService.new.mark_todos_as_done([todo], current_user)
+ TodoService.new.mark_todos_as_done_by_id([params[:id]], current_user)
respond_to do |format|
format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' }
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb
index eb833dd82ac..5a2f7946082 100644
--- a/app/services/todo_service.rb
+++ b/app/services/todo_service.rb
@@ -142,7 +142,11 @@ class TodoService
# When user marks some todos as done
def mark_todos_as_done(todos, current_user)
- todos = current_user.todos.where(id: todos.map(&:id)) unless todos.respond_to?(:update_all)
+ mark_todos_as_done_by_id(todos.select(&:id), current_user)
+ end
+
+ def mark_todos_as_done_by_id(ids, current_user)
+ todos = current_user.todos.where(id: ids)
marked_todos = todos.update_all(state: :done)
current_user.update_todos_count_cache