diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 32f5c09eac1b84aa4f3c8458be78de4e55dc75c6..c8390af3b3622bbe62acffe16f067f93c2ec4121 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -6,7 +6,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def destroy - TodoService.new.mark_todos_as_done_by_id([params[:id]], current_user) + TodoService.new.mark_todos_as_done_by_ids([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 5a2f79460828798f530057da9e25196598d03f65..daf4339cb48cde2640100e0ddfe1ba42b9c3c2c5 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -142,10 +142,10 @@ class TodoService # When user marks some todos as done def mark_todos_as_done(todos, current_user) - mark_todos_as_done_by_id(todos.select(&:id), current_user) + mark_todos_as_done_by_ids(todos.select(&:id), current_user) end - def mark_todos_as_done_by_id(ids, current_user) + def mark_todos_as_done_by_ids(ids, current_user) todos = current_user.todos.where(id: ids) marked_todos = todos.update_all(state: :done) diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 9db05cce732cd152e5748cb26331bc8bc5864548..a2a1d5e6d3076f31ad6c35e4fb81bad7fd2fcb08 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -225,8 +225,8 @@ describe TodoService, services: true do end end - describe '#mark_todos_as_done_by_id' do - it_behaves_like 'marking todos as done', :mark_todos_as_done_by_id do + describe '#mark_todos_as_done_by_ids' do + it_behaves_like 'marking todos as done', :mark_todos_as_done_by_ids do let(:collection) { [first_todo, second_todo].map(&:id) } end end