From f14965fac774465c0179f5e318c9df3df9b6a05d Mon Sep 17 00:00:00 2001 From: radhika Date: Tue, 28 Mar 2017 12:54:56 -0400 Subject: [PATCH] 3821: The "Remove selected files" option should only be presented if the user can update the collection. --- .../workbench/app/helpers/application_helper.rb | 2 +- .../app/views/collections/_show_files.html.erb | 4 +++- .../test/integration/collections_test.rb | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb index 0dc16fbb44..056f12f6c8 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -274,7 +274,7 @@ module ApplicationHelper "data-placement" => "bottom", "data-type" => input_type, "data-title" => "Edit #{attr.to_s.gsub '_', ' '}", - "data-name" => htmloptions['selection_path'] || attr, + "data-name" => htmloptions['selection_name'] || attr, "data-object-uuid" => object.uuid, "data-toggle" => "manual", "data-value" => htmloptions['data-value'] || attrvalue, diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb index fc1ca58d2a..37d9283dbd 100644 --- a/apps/workbench/app/views/collections/_show_files.html.erb +++ b/apps/workbench/app/views/collections/_show_files.html.erb @@ -27,6 +27,7 @@ 'data-selection-action' => 'combine-collections', 'data-toggle' => 'dropdown' %> + <% if @object.editable? %>
  • <%= link_to "Remove selected files", '#', method: :post, 'data-href' => url_for(action: :remove_selected_files), @@ -34,6 +35,7 @@ 'data-selection-action' => 'remove-selected-files', 'data-toggle' => 'dropdown' %>
  • + <% end %>
    @@ -115,7 +117,7 @@
    <% else %> <% if @object.editable? %> - <%= render_editable_attribute @object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path} %> + <%= render_editable_attribute @object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path} %> <% else %> <%= filename %> <% end %> diff --git a/apps/workbench/test/integration/collections_test.rb b/apps/workbench/test/integration/collections_test.rb index 2685e521f1..eb9c2e831a 100644 --- a/apps/workbench/test/integration/collections_test.rb +++ b/apps/workbench/test/integration/collections_test.rb @@ -340,4 +340,21 @@ class CollectionsTest < ActionDispatch::IntegrationTest assert(page.has_text?('file1renamed'), 'file not found - file1renamed') end + + test "remove/rename file options not presented if user cannot update a collection" do + # visit a publicly accessible collection as 'spectator' + visit page_with_token('spectator', '/collections/zzzzz-4zz18-uukreo9rbgwsujr') + + click_button 'Selection' + within('.selection-action-container') do + assert_selector 'li', text: 'Create new collection with selected files' + assert_no_selector 'li', text: 'Remove selected files' + end + + within('.collection_files') do + assert(page.has_text?('GNU_General_Public_License'), 'file not found - GNU_General_Public_License') + assert_nil first('.fa-pencil') + assert_nil first('.fa-trash-o') + end + end end -- 2.30.2