From: Tim Pierce Date: Tue, 30 Sep 2014 04:42:16 +0000 (-0400) Subject: 3961: test creating subprojects under home with duplicate names X-Git-Tag: 1.1.0~2148^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/dc29394d6e4df36a1cab5beae69c3331e037bdb1?hp=99ba15c7f425c042fb61b454bba27324c80b7649 3961: test creating subprojects under home with duplicate names New tests: * unprivileged user creating a subproject under their home project, with an existing name, returns 422 * unprivileged user creating a subproject under their home project, with an existing name, and ensure_unique_name=true, succeeds --- diff --git a/services/api/test/functional/arvados/v1/groups_controller_test.rb b/services/api/test/functional/arvados/v1/groups_controller_test.rb index de339c9554..5a67b5cbfc 100644 --- a/services/api/test/functional/arvados/v1/groups_controller_test.rb +++ b/services/api/test/functional/arvados/v1/groups_controller_test.rb @@ -329,4 +329,31 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase users(:admin).uuid, "Current user should be included in 'writable_by' field") end + + test 'creating subproject with duplicate name fails' do + authorize_with :active + post :create, { + group: { + name: 'A Project', + owner_uuid: users(:active).uuid, + group_class: 'project', + }, + } + assert_response 422 + end + + test 'creating duplicate named subproject succeeds with ensure_unique_name' do + authorize_with :active + post :create, { + group: { + name: 'A Project', + owner_uuid: users(:active).uuid, + group_class: 'project', + }, + ensure_unique_name: true + } + assert_response :success + assert_not_equal json_response['uuid'], groups(:aproject).uuid + assert_equal json_response['name'], 'A Project (2)' + end end