[ARVADOS] created: 99ba15c7f425c042fb61b454bba27324c80b7649
git at public.curoverse.com
git at public.curoverse.com
Mon Sep 29 11:34:49 EDT 2014
at 99ba15c7f425c042fb61b454bba27324c80b7649 (commit)
commit 99ba15c7f425c042fb61b454bba27324c80b7649
Author: Tim Pierce <twp at curoverse.com>
Date: Mon Sep 29 11:06:49 2014 -0400
3961: reset object UUID when ensure_unique_name is set
When saving an object that has to be renamed with ensure_unique_name,
force @object.uuid to nil so that validate_uuid will not be confused
into thinking we are trying to reassign the uuid.
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 3465a78..381c5c9 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -101,6 +101,7 @@ class ApplicationController < ActionController::Base
logger.error "params[:ensure_unique_name] is #{params[:ensure_unique_name]}"
if params[:ensure_unique_name]
counter += 1
+ @object.uuid = nil
@object.name = "#{name_stem} (#{counter})"
retry_save = true
end
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index 16da08f..817fd5c 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -10,6 +10,18 @@ user_agreement:
manifest_text: ". 6a4ff0499484c6c79c95cd8c566bd25f+249025 0:249025:GNU_General_Public_License,_version_3.pdf\n"
name: user_agreement
+collection_owned_by_active:
+ uuid: zzzzz-4zz18-bv31uwvy3neko21
+ portable_data_hash: fa7aeb5140e2848d39b416daeef4ffc5+45
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ created_at: 2014-02-03T17:22:54Z
+ modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+ modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+ modified_at: 2014-02-03T17:22:54Z
+ updated_at: 2014-02-03T17:22:54Z
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+ name: owned_by_active
+
foo_file:
uuid: zzzzz-4zz18-znfnqtbbv4spc3w
portable_data_hash: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45
diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index f2c15c6..6f3e2c8 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -149,22 +149,22 @@ EOS
assert_response 422
end
- test "create succeeds with with duplicate name with ensure_unique_name" do
+ test "create succeeds with duplicate name with ensure_unique_name" do
permit_unsigned_manifests
- authorize_with :admin
+ authorize_with :active
manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
post :create, {
collection: {
- owner_uuid: 'zzzzz-tpzed-000000000000000',
+ owner_uuid: users(:active).uuid,
manifest_text: manifest_text,
portable_data_hash: "d30fe8ae534397864cb96c544f4cf102+47",
- name: "foo_file"
+ name: "owned_by_active"
},
ensure_unique_name: true
}
assert_response :success
resp = JSON.parse(@response.body)
- assert_equal 'foo_file (2)', resp['name']
+ assert_equal 'owned_by_active (2)', resp['name']
end
test "create with owner_uuid set to group i can_manage" do
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list