X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/aa12c56d26cb72824ddd2399e17e846cd9d9b483..0f644e242ef37c911ad3dc25aca8135c339de349:/services/api/test/functional/arvados/v1/collections_controller_test.rb 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 055af9e67c..56b0790a0a 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class Arvados::V1::CollectionsControllerTest < ActionController::TestCase @@ -1045,7 +1049,7 @@ EOS [:active, :admin].each do |user| test "get trashed collections as #{user}" do - authorize_with :active + authorize_with user get :index, { filters: [["is_trashed", "=", true]], include_trash: true, @@ -1065,4 +1069,25 @@ EOS end end end + + test 'untrash collection with same name as another with no ensure unique name' do + authorize_with :active + post :untrash, { + id: collections(:trashed_collection_to_test_name_conflict_on_untrash).uuid, + } + assert_response 422 + end + + test 'untrash collection with same name as another with ensure unique name' do + authorize_with :active + post :untrash, { + id: collections(:trashed_collection_to_test_name_conflict_on_untrash).uuid, + ensure_unique_name: true + } + assert_response 200 + assert_equal false, json_response['is_trashed'] + assert_nil json_response['trash_at'] + assert_nil json_response['delete_at'] + assert_match /^same name for trashed and persisted collections \(\d{4}-\d\d-\d\d.*?Z\)$/, json_response['name'] + end end