diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-16 20:56:23 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-18 11:00:53 -0300 |
commit | fb72271e24663c74e6dd66e610fd1add98628648 (patch) | |
tree | 35f8efea08d81fde6bdf5f5e48c86ecbbe2e5ce4 | |
parent | c29da3f8ca1d759b8cbecb91b6e0529b18cc5c85 (diff) | |
download | gitlab-ce-fb72271e24663c74e6dd66e610fd1add98628648.tar.gz |
Use todo.done without ! in the controller to mark todo as done
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 4 | ||||
-rw-r--r-- | app/models/todo.rb | 2 | ||||
-rw-r--r-- | spec/models/todo_spec.rb | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 7857af9c5de..be488483b09 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 - todo.done! + todo.done todo_notice = 'Todo was successfully marked as done.' @@ -20,7 +20,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def destroy_all - @todos.each(&:done!) + @todos.each(&:done) respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' } diff --git a/app/models/todo.rb b/app/models/todo.rb index b00a1b3dc7d..68263a64d5a 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -38,7 +38,7 @@ class Todo < ActiveRecord::Base state_machine :state, initial: :pending do event :done do - transition [:pending, :done] => :done + transition [:pending] => :done end state :pending diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 3e59443589c..76182863024 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -73,15 +73,15 @@ describe Todo, models: true do end end - describe '#done!' do + describe '#done' do it 'changes state to done' do todo = create(:todo, state: :pending) - expect { todo.done! }.to change(todo, :state).from('pending').to('done') + expect { todo.done }.to change(todo, :state).from('pending').to('done') end it 'does not raise error when is already done' do todo = create(:todo, state: :done) - expect { todo.done! }.not_to raise_error + expect { todo.done }.not_to raise_error end end |