[ARVADOS] updated: 694f3f5c05a37cdf6e70a164b0c8dd8171b97cda

Git user git at public.curoverse.com
Wed Jun 21 11:48:32 EDT 2017


Summary of changes:
 .../app/views/collections/_show_tag_rows.html.erb  | 10 ++--
 .../controllers/collections_controller_test.rb     | 56 ++++++++++++++++++++++
 services/api/test/fixtures/collections.yml         | 17 +++++++
 services/api/test/fixtures/links.yml               | 14 ++++++
 4 files changed, 94 insertions(+), 3 deletions(-)

       via  694f3f5c05a37cdf6e70a164b0c8dd8171b97cda (commit)
      from  8eef061d1e3c8fcc03b89637e18c91e04689614f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 694f3f5c05a37cdf6e70a164b0c8dd8171b97cda
Author: radhika <radhika at curoverse.com>
Date:   Wed Jun 21 11:47:38 2017 -0400

    9426: test collection tags update for a collection with other properties
    
    Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>

diff --git a/apps/workbench/app/views/collections/_show_tag_rows.html.erb b/apps/workbench/app/views/collections/_show_tag_rows.html.erb
index 8d2ae7b..eceec10 100644
--- a/apps/workbench/app/views/collections/_show_tag_rows.html.erb
+++ b/apps/workbench/app/views/collections/_show_tag_rows.html.erb
@@ -1,11 +1,13 @@
 <%
   tags = object.properties[:tags]
 %>
-        <% if tags.andand.is_a?(Hash) %>
+      <% if tags.andand.is_a?(Hash) %>
         <% tags.each do |k, v| %>
           <tr class="collection-tag-<%=k%>">
             <td>
-              <i class="glyphicon glyphicon-remove collection-tag-remove hide" style="cursor: pointer;"></i>
+              <% if object.editable? %>
+                <i class="glyphicon glyphicon-remove collection-tag-remove hide" style="cursor: pointer;"></i>
+              <% end %>
             </td>
             <td class="collection-tag-field collection-tag-field-key">
               <%= k %>
@@ -15,8 +17,9 @@
             </td>
           </tr>
         <% end %>
-        <% end %>
+      <% end %>
 
+      <% if @object.editable? %>
         <!-- A hidden row to add new tag -->
         <tr class="collection-tag-hidden hide">
           <td>
@@ -25,3 +28,4 @@
           <td class="collection-tag-field collection-tag-field-key"></td>
           <td class="collection-tag-field collection-tag-field-value"></td>
         </tr>
+      <% end %>
diff --git a/apps/workbench/test/controllers/collections_controller_test.rb b/apps/workbench/test/controllers/collections_controller_test.rb
index 1632dd0..257f829 100644
--- a/apps/workbench/test/controllers/collections_controller_test.rb
+++ b/apps/workbench/test/controllers/collections_controller_test.rb
@@ -762,4 +762,60 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_response 422
     assert_includes json_response['errors'], 'Duplicate file path'
   end
+
+  [
+    [:active, true],
+    [:spectator, false],
+  ].each do |user, editable|
+    test "tags tab #{editable ? 'shows' : 'does not show'} edit button to #{user}" do
+      use_token user
+
+      get :tags, {
+        id: api_fixture('collections')['collection_with_tags_owned_by_active']['uuid'],
+        format: :js,
+      }, session_for(user)
+
+      assert_response :success
+
+      found = 0
+      response.body.scan /<i[^>]+>/ do |remove_icon|
+        remove_icon.scan(/\ collection-tag-remove(.*?)\"/).each do |i,|
+          found += 1
+        end
+      end
+
+      if editable
+        assert_equal(3, found)  # two from the tags + 1 from the hidden "add tag" row
+      else
+        assert_equal(0, found)
+      end
+    end
+  end
+
+  test "save_tags and verify that 'other' properties are retained" do
+    use_token :active
+
+    collection = api_fixture('collections')['collection_with_tags_owned_by_active']
+
+    new_tags = {"new_tag1": "new_tag1_value", "new_tag2": "new_tag2_value"}
+
+    post :save_tags, {
+      id: collection['uuid'],
+      tag_data: new_tags,
+      format: :js,
+    }, session_for(:active)
+
+    assert_response :success
+    assert_equal true, response.body.include?("new_tag1")
+    assert_equal true, response.body.include?("new_tag1_value")
+    assert_equal true, response.body.include?("new_tag2")
+    assert_equal true, response.body.include?("new_tag2_value")
+    assert_equal false, response.body.include?("existing tag 1")
+    assert_equal false, response.body.include?("value for existing tag 1")
+
+    updated_properties = Collection.find(collection['uuid']).properties
+    assert_equal new_tags, updated_properties[:tags]
+    assert_equal true, updated_properties.keys.include?(:'some other property')
+    assert_equal 'value for the other property', updated_properties[:'some other property']
+  end
 end
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index 8aedbdc..6543f54 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -657,6 +657,23 @@ collection_to_remove_and_rename_files:
   manifest_text: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n"
   name: collection to remove and rename files
 
+collection_with_tags_owned_by_active:
+  uuid: zzzzz-4zz18-taggedcolletion
+  portable_data_hash: fa7aeb5140e2848d39b416daeef4ffc5+45
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-02-03T17:22:54Z
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  modified_at: 2014-02-03T17:22:54Z
+  updated_at: 2014-02-03T17:22:54Z
+  manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+  name: collection with tags
+  properties:
+    tags:
+      existing tag 1: value for existing tag 1
+      existing tag 2: value for existing tag 2
+    some other property: value for the other property
+
 
 # Test Helper trims the rest of the file
 
diff --git a/services/api/test/fixtures/links.yml b/services/api/test/fixtures/links.yml
index ac579f7..2c65483 100644
--- a/services/api/test/fixtures/links.yml
+++ b/services/api/test/fixtures/links.yml
@@ -1056,3 +1056,17 @@ star_shared_project_for_project_viewer:
   name: zzzzz-j7d0g-starredshared01
   head_uuid: zzzzz-j7d0g-starredshared01
   properties: {}
+
+tagged_collection_readable_by_spectator:
+  uuid: zzzzz-o0j2j-readacl4tagcoll
+  owner_uuid: zzzzz-tpzed-000000000000000
+  created_at: 2014-01-24 20:42:26 -0800
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-000000000000000
+  modified_at: 2014-01-24 20:42:26 -0800
+  updated_at: 2014-01-24 20:42:26 -0800
+  tail_uuid: zzzzz-tpzed-l1s2piq4t4mps8r
+  link_class: permission
+  name: can_read
+  head_uuid: zzzzz-4zz18-taggedcolletion
+  properties: {}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list