Commit b68edb0c authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '214469-fix-updated-at-on-todos' into 'master'

Update updated_at when Todo state changes

See merge request gitlab-org/gitlab!29930
parents 88e9da30 2f864047
...@@ -110,7 +110,7 @@ class Todo < ApplicationRecord ...@@ -110,7 +110,7 @@ class Todo < ApplicationRecord
base = where.not(state: new_state).except(:order) base = where.not(state: new_state).except(:order)
ids = base.pluck(:id) ids = base.pluck(:id)
base.update_all(state: new_state) base.update_all(state: new_state, updated_at: Time.now)
ids ids
end end
......
...@@ -389,5 +389,17 @@ describe Todo do ...@@ -389,5 +389,17 @@ describe Todo do
expect(described_class.update_state(:pending)).to be_empty expect(described_class.update_state(:pending)).to be_empty
end 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
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment