11840: support ensure_unique_name parameter in collection untrash method
[arvados.git] / services / api / test / functional / arvados / v1 / collections_controller_test.rb
index 17af916b3df244821bc596bbbc58fad799d8d380..70f35f3dd2b54f51f00edee2deed4aa8dd265e3b 100644 (file)
@@ -1065,4 +1065,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