[ARVADOS] created: 75eaaaa74a4a7ec6821008fe93dbee598ee24dee

git at public.curoverse.com git at public.curoverse.com
Thu Aug 6 10:59:21 EDT 2015


        at  75eaaaa74a4a7ec6821008fe93dbee598ee24dee (commit)


commit 75eaaaa74a4a7ec6821008fe93dbee598ee24dee
Author: radhika <radhika at curoverse.com>
Date:   Thu Aug 6 10:57:14 2015 -0400

    6880: Omit delete button from users index table; add controller tests.
    6916: Show Home link in users page only and not in all other pages accessed via admin settings menu such as /repositories page; add controller tests.

diff --git a/apps/workbench/app/views/application/_show_recent.html.erb b/apps/workbench/app/views/application/_show_recent.html.erb
index dd6876d..f423c04 100644
--- a/apps/workbench/app/views/application/_show_recent.html.erb
+++ b/apps/workbench/app/views/application/_show_recent.html.erb
@@ -8,7 +8,8 @@
 
 <% attr_blacklist = ' created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at owner_uuid group_class properties' %>
 
-<% show_home_link = current_user.is_admin and controller.model_class == User %>
+<% show_home_link = (current_user.is_admin and controller.model_class == User) %>
+<% show_delete_btn = (controller.model_class != User) %>
 
 <%= render partial: "paging", locals: {results: objects, object: @object} %>
 
@@ -66,7 +67,9 @@
         </td>
       <% end %>
       <td>
-        <%= render partial: 'delete_object_button', locals: {object:object} %>
+        <% if show_delete_btn %>
+          <%= render partial: 'delete_object_button', locals: {object:object} %>
+        <% end %>
       </td>
     </tr>
     <% end %>
diff --git a/apps/workbench/test/controllers/application_controller_test.rb b/apps/workbench/test/controllers/application_controller_test.rb
index 3504d95..6daa63f 100644
--- a/apps/workbench/test/controllers/application_controller_test.rb
+++ b/apps/workbench/test/controllers/application_controller_test.rb
@@ -418,4 +418,45 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_equal updated.uuid, project["uuid"]
     assert_equal 'test name', updated.name
   end
+
+  [
+    [VirtualMachinesController.new, 'hostname', false],
+    [UsersController.new, 'first_name', true],
+  ].each do |controller, expect_str, expect_home_link=false|
+    test "access #{controller.controller_name} index as admin and verify Home link is#{' not' if !expect_home_link} shown" do
+      @controller = controller
+
+      get :index, {}, session_for(:admin)
+
+      assert_response 200
+      assert_includes @response.body, expect_str
+
+      home_link = "/projects/#{api_fixture('users')['active']['uuid']}"
+
+      if expect_home_link
+        refute_empty css_select("[href=\"/projects/#{api_fixture('users')['active']['uuid']}\"]")
+      else
+        assert_empty css_select("[href=\"/projects/#{api_fixture('users')['active']['uuid']}\"]")
+      end
+    end
+  end
+
+  [
+    [VirtualMachinesController.new, 'hostname', true],
+    [UsersController.new, 'first_name', false],
+  ].each do |controller, expect_str, expect_delete_link=false|
+    test "access #{controller.controller_name} index as admin and verify Delete option is#{' not' if !expect_delete_link} shown" do
+      @controller = controller
+
+      get :index, {}, session_for(:admin)
+
+      assert_response 200
+      assert_includes @response.body, expect_str
+      if expect_delete_link
+        refute_empty css_select('[data-method=delete]')
+      else
+        assert_empty css_select('[data-method=delete]')
+      end
+    end
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list