11846: update file path parameter name in renaming collection image files and add...
authorradhika <radhika@curoverse.com>
Thu, 22 Jun 2017 14:21:06 +0000 (10:21 -0400)
committerradhika <radhika@curoverse.com>
Thu, 22 Jun 2017 18:07:24 +0000 (14:07 -0400)
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>

apps/workbench/app/views/collections/_show_files.html.erb
apps/workbench/test/controllers/collections_controller_test.rb

index 7c7777d472e3cb48ff5b28a2c7d67d16e30a638d..2c568fb6a53f61af00e2ebfff3b281949944510b 100644 (file)
             <i class="fa fa-fw fa-bar-chart-o"></i>
               <% if object.editable? %>
                 <span class="btn-collection-rename-file-span">
             <i class="fa fa-fw fa-bar-chart-o"></i>
               <% if object.editable? %>
                 <span class="btn-collection-rename-file-span">
-                <%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file', btnclass: 'collection-file-control'} %>
+                <%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file', btnclass: 'collection-file-control'} %>
                 </span>
               <% else %>
                 <%= filename %>
                 </span>
               <% else %>
                 <%= filename %>
index 1632dd0653b11d82d9a97e245bc9dd55db5ccc1d..7ff123cd452c9da367e177f0a93a9071d2c01d67 100644 (file)
@@ -686,7 +686,7 @@ class CollectionsControllerTest < ActionController::TestCase
     use_token :active
 
     # create a new collection to test
     use_token :active
 
     # create a new collection to test
-    manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:dir1file1 0:0:dir1file2\n"
+    manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png\n"
 
     collection = Collection.create(manifest_text: manifest_text)
     assert_includes(collection['manifest_text'], "0:0:file1")
 
     collection = Collection.create(manifest_text: manifest_text)
     assert_includes(collection['manifest_text'], "0:0:file1")
@@ -702,7 +702,7 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
-    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed 0:0:file2\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2\n$/, collection['manifest_text']
+    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed 0:0:file2\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png\n$/, collection['manifest_text']
 
     # now rename 'file2' such that it is moved into 'dir1'
     @test_counter = 0
 
     # now rename 'file2' such that it is moved into 'dir1'
     @test_counter = 0
@@ -716,7 +716,7 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
-    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:file2\n$/, collection['manifest_text']
+    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n$/, collection['manifest_text']
 
     # now rename 'dir1/dir1file1' such that it is moved into a new subdir
     @test_counter = 0
 
     # now rename 'dir1/dir1file1' such that it is moved into a new subdir
     @test_counter = 0
@@ -730,7 +730,21 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_response :success
 
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
-    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
+    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
+
+    # now rename the image file 'dir1/dir1imagefile.png'
+    @test_counter = 0
+    post :update, {
+      id: collection['uuid'],
+      collection: {
+        'rename-file-path:dir1/dir1imagefile.png' => 'dir1/dir1imagefilerenamed.png'
+      },
+      format: :json
+    }, session_for(:active)
+    assert_response :success
+
+    collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
+    assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefilerenamed.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
   end
 
   test "renaming file with a duplicate name in same stream not allowed" do
   end
 
   test "renaming file with a duplicate name in same stream not allowed" do