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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
28097398
Commit
28097398
authored
Feb 22, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not raise an error when Todo is already marked as done
parent
f5be5671
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
29 deletions
+9
-29
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+1
-1
app/models/todo.rb
app/models/todo.rb
+1
-1
spec/models/todo_spec.rb
spec/models/todo_spec.rb
+7
-27
No files found.
app/controllers/dashboard/todos_controller.rb
View file @
28097398
...
@@ -15,7 +15,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
...
@@ -15,7 +15,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end
end
def
destroy_all
def
destroy_all
@todos
.
each
(
&
:done
)
@todos
.
each
(
&
:done
!
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
...
...
app/models/todo.rb
View file @
28097398
...
@@ -36,7 +36,7 @@ class Todo < ActiveRecord::Base
...
@@ -36,7 +36,7 @@ class Todo < ActiveRecord::Base
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
event
:done
do
event
:done
do
transition
pending:
:done
transition
[
:pending
,
:done
]
=>
:done
end
end
state
:pending
state
:pending
...
...
spec/models/todo_spec.rb
.rb
→
spec/models/todo_spec.rb
View file @
28097398
...
@@ -37,20 +37,6 @@ describe Todo, models: true do
...
@@ -37,20 +37,6 @@ describe Todo, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
end
end
describe
'#action_name'
do
it
'returns proper message when action is an assigment'
do
subject
.
action
=
Todo
::
ASSIGNED
expect
(
subject
.
action_name
).
to
eq
'assigned'
end
it
'returns proper message when action is a mention'
do
subject
.
action
=
Todo
::
MENTIONED
expect
(
subject
.
action_name
).
to
eq
'mentioned you on'
end
end
describe
'#body'
do
describe
'#body'
do
before
do
before
do
subject
.
target
=
build
(
:issue
,
title:
'Bugfix'
)
subject
.
target
=
build
(
:issue
,
title:
'Bugfix'
)
...
@@ -69,21 +55,15 @@ describe Todo, models: true do
...
@@ -69,21 +55,15 @@ describe Todo, models: true do
end
end
end
end
describe
'#target_iid'
do
describe
'#done!'
do
let
(
:issue
)
{
build
(
:issue
,
id:
1
,
iid:
5
)
}
it
'changes state to done'
do
todo
=
create
(
:todo
,
state: :pending
)
before
do
expect
{
todo
.
done!
}.
to
change
(
todo
,
:state
).
from
(
'pending'
).
to
(
'done'
)
subject
.
target
=
issue
end
it
'returns target.iid when target respond to iid'
do
expect
(
subject
.
target_iid
).
to
eq
5
end
end
it
'returns target_id when target does not respond to iid'
do
it
'does not raise error when is already done'
do
allow
(
issue
).
to
receive
(
:respond_to?
).
with
(
:iid
).
and_return
(
false
)
todo
=
create
(
:todo
,
state: :done
)
expect
{
todo
.
done!
}.
not_to
raise_error
expect
(
subject
.
target_iid
).
to
eq
1
end
end
end
end
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