Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
fb72271e
Commit
fb72271e
authored
Mar 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use todo.done without ! in the controller to mark todo as done
parent
c29da3f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+2
-2
app/models/todo.rb
app/models/todo.rb
+1
-1
spec/models/todo_spec.rb
spec/models/todo_spec.rb
+3
-3
No files found.
app/controllers/dashboard/todos_controller.rb
View file @
fb72271e
...
...
@@ -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.'
}
...
...
app/models/todo.rb
View file @
fb72271e
...
...
@@ -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
...
...
spec/models/todo_spec.rb
View file @
fb72271e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment