[ARVADOS] created: 2.1.0-174-gb3fad38bb
Git user
git at public.arvados.org
Wed Dec 2 13:52:51 UTC 2020
at b3fad38bb4fd356e5ce924e792be7f4113d1c746 (commit)
commit b3fad38bb4fd356e5ce924e792be7f4113d1c746
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Tue Dec 1 19:17:01 2020 -0300
17152: Fixes old collection versions' modified_at handling and test.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 8b549a71a..3637f34e1 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -269,6 +269,7 @@ class Collection < ArvadosModel
snapshot = self.dup
snapshot.uuid = nil # Reset UUID so it's created as a new record
snapshot.created_at = self.created_at
+ snapshot.modified_at = self.modified_at_was
end
# Restore requested changes on the current version
@@ -294,8 +295,10 @@ class Collection < ArvadosModel
if snapshot
snapshot.attributes = self.syncable_updates
leave_modified_by_user_alone do
- act_as_system_user do
- snapshot.save
+ leave_modified_at_alone do
+ act_as_system_user do
+ snapshot.save
+ end
end
end
end
diff --git a/services/api/test/unit/collection_test.rb b/services/api/test/unit/collection_test.rb
index 48cae5afe..666d41f0e 100644
--- a/services/api/test/unit/collection_test.rb
+++ b/services/api/test/unit/collection_test.rb
@@ -334,6 +334,7 @@ class CollectionTest < ActiveSupport::TestCase
# Set up initial collection
c = create_collection 'foo', Encoding::US_ASCII
assert c.valid?
+ original_version_modified_at = c.modified_at.to_f
# Make changes so that a new version is created
c.update_attributes!({'name' => 'bar'})
c.reload
@@ -344,9 +345,7 @@ class CollectionTest < ActiveSupport::TestCase
version_creation_datetime = c_old.modified_at.to_f
assert_equal c.created_at.to_f, c_old.created_at.to_f
- # Current version is updated just a few milliseconds before the version is
- # saved on the database.
- assert_operator c.modified_at.to_f, :<, version_creation_datetime
+ assert_equal original_version_modified_at, version_creation_datetime
# Make update on current version so old version get the attribute synced;
# its modified_at should not change.
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list