Rename TodoService#mark_todos_as_done_by_id{,s}

This commit is contained in:
Ahmad Sherif 2016-08-17 21:54:31 +02:00
parent 548da42be5
commit 4ad028aed4
3 changed files with 5 additions and 5 deletions

View file

@ -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.' }

View file

@ -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)

View file

@ -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