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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2f864047
Commit
2f864047
authored
Apr 20, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update updated_at when Todo state changes
parent
3ed77673
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
app/models/todo.rb
app/models/todo.rb
+1
-1
spec/models/todo_spec.rb
spec/models/todo_spec.rb
+12
-0
No files found.
app/models/todo.rb
View file @
2f864047
...
...
@@ -110,7 +110,7 @@ class Todo < ApplicationRecord
base
=
where
.
not
(
state:
new_state
).
except
(
:order
)
ids
=
base
.
pluck
(
:id
)
base
.
update_all
(
state:
new_state
)
base
.
update_all
(
state:
new_state
,
updated_at:
Time
.
now
)
ids
end
...
...
spec/models/todo_spec.rb
View file @
2f864047
...
...
@@ -389,5 +389,17 @@ describe Todo do
expect
(
described_class
.
update_state
(
:pending
)).
to
be_empty
end
it
'updates updated_at'
do
create
(
:todo
,
:pending
)
Timecop
.
freeze
(
1
.
day
.
from_now
)
do
expected_update_date
=
Time
.
now
.
utc
ids
=
described_class
.
update_state
(
:done
)
expect
(
Todo
.
where
(
id:
ids
).
map
(
&
:updated_at
)).
to
all
(
be_like_time
(
expected_update_date
))
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