Merge branch '14860-fix-collection-versioning'
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 19 Feb 2019 20:21:32 +0000 (17:21 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 19 Feb 2019 20:25:28 +0000 (17:25 -0300)
Closes #14860

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/api/app/models/collection.rb
services/api/test/functional/arvados/v1/collections_controller_test.rb

index 33cc686d4f5a14f3a432bc3df077ab258797a4a8..6147b79f9f5aa16c6b9e24ef5164bab43139373a 100644 (file)
@@ -262,6 +262,7 @@ class Collection < ArvadosModel
       sync_past_versions if syncable_updates.any?
       if snapshot
         snapshot.attributes = self.syncable_updates
+        snapshot.manifest_text = snapshot.signed_manifest_text
         snapshot.save
       end
     end
index 26b8290e6961452e97f505ad3b239f6ef5a28596..997d89d5cd13d72c97dd3edcaa177bca36e1efed 100644 (file)
@@ -1279,7 +1279,6 @@ EOS
         version: 42,
         current_version_uuid: collections(:collection_owned_by_active).uuid,
         manifest_text: manifest_text,
-        # portable_data_hash: "d30fe8ae534397864cb96c544f4cf102+47"
       }
     }
     assert_response :success
@@ -1287,4 +1286,28 @@ EOS
     assert_equal 1, resp['version']
     assert_equal resp['uuid'], resp['current_version_uuid']
   end
+
+  test "update collection with versioning enabled" do
+    Rails.configuration.collection_versioning = true
+    Rails.configuration.preserve_version_if_idle = 1 # 1 second
+
+    col = collections(:collection_owned_by_active)
+    assert_equal 2, col.version
+    assert col.modified_at < Time.now - 1.second
+
+    token = api_client_authorizations(:active).v2token
+    signed = Blob.sign_locator(
+      'acbd18db4cc2f85cedef654fccc4a4d8+3',
+      key: Rails.configuration.blob_signing_key,
+      api_token: token)
+    authorize_with_token token
+    put :update, {
+          id: col.uuid,
+          collection: {
+            manifest_text: ". #{signed} 0:3:foo.txt\n",
+          },
+        }
+    assert_response :success
+    assert_equal 3, json_response['version']
+  end
 end