11840: include ensure_unique_name parameter in untrash requests from workbench.
authorradhika <radhika@curoverse.com>
Thu, 22 Jun 2017 19:40:40 +0000 (15:40 -0400)
committerradhika <radhika@curoverse.com>
Thu, 22 Jun 2017 19:40:40 +0000 (15:40 -0400)
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>

apps/workbench/app/models/collection.rb
apps/workbench/test/controllers/trash_items_controller_test.rb [new file with mode: 0644]

index 305ea015306fe898c97bd16b443a13d9ff230781..025c136d41bed69883a80d0cc12cbc3bfdf43ec9 100644 (file)
@@ -99,6 +99,6 @@ class Collection < ArvadosBase
   end
 
   def untrash
-    arvados_api_client.api(self.class, "/#{self.uuid}/untrash", {})
+    arvados_api_client.api(self.class, "/#{self.uuid}/untrash", {"ensure_unique_name" => true})
   end
 end
diff --git a/apps/workbench/test/controllers/trash_items_controller_test.rb b/apps/workbench/test/controllers/trash_items_controller_test.rb
new file mode 100644 (file)
index 0000000..c530ba9
--- /dev/null
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class TrashItemsControllerTest < ActionController::TestCase
+  test "untrash collection with same name as another collection" do
+    collection = api_fixture('collections')['trashed_collection_to_test_name_conflict_on_untrash']
+    items = [collection['uuid']]
+    post :untrash_items, {
+      selection: items,
+      format: :js
+    }, session_for(:active)
+
+    assert_response :success
+  end
+end