Commit 4ad028ae authored by Ahmad Sherif's avatar Ahmad Sherif

Rename TodoService#mark_todos_as_done_by_id{,s}

parent 548da42b
...@@ -6,7 +6,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController ...@@ -6,7 +6,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end end
def destroy 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| respond_to do |format|
format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' } format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' }
......
...@@ -142,10 +142,10 @@ class TodoService ...@@ -142,10 +142,10 @@ class TodoService
# When user marks some todos as done # When user marks some todos as done
def mark_todos_as_done(todos, current_user) 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 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) todos = current_user.todos.where(id: ids)
marked_todos = todos.update_all(state: :done) marked_todos = todos.update_all(state: :done)
......
...@@ -225,8 +225,8 @@ describe TodoService, services: true do ...@@ -225,8 +225,8 @@ describe TodoService, services: true do
end end
end end
describe '#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_id do it_behaves_like 'marking todos as done', :mark_todos_as_done_by_ids do
let(:collection) { [first_todo, second_todo].map(&:id) } let(:collection) { [first_todo, second_todo].map(&:id) }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment