6234: In /users page, display the "Show" button to admin users as well; however,...
authorradhika <radhika@curoverse.com>
Wed, 17 Jun 2015 18:11:27 +0000 (14:11 -0400)
committerradhika <radhika@curoverse.com>
Wed, 17 Jun 2015 18:11:27 +0000 (14:11 -0400)
projects/{user-uuid} takes user to user's home project while /users/{user-uuid} takes to user's page.
Also, move should correctly display user's home project.

apps/workbench/app/controllers/actions_controller.rb
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/application/_show_recent.html.erb
apps/workbench/test/integration/search_box_test.rb
apps/workbench/test/integration/users_test.rb

index e6ef6eb894d9ca3e6aad25aba909bcbbb0f32305..cbe7e37fe5ca4c7f38b1b642db9f62294414aacb 100644 (file)
@@ -91,7 +91,8 @@ class ActionsController < ApplicationController
     end
     if (resource_classes == [Collection] and
         @object.is_a? Group and
-        @object.group_class == 'project')
+        @object.group_class == 'project') or
+        @object.is_a? User
       # In the common case where only collections are copied/moved
       # into a project, it's polite to land on the collections tab on
       # the destination project.
index ac3ea606e9f7421fca4b867be61f7a21a1180ece..2f513655b6e9424374f0ed90d559acc9a711d236 100644 (file)
@@ -9,7 +9,11 @@ class UsersController < ApplicationController
     if params[:uuid] == current_user.uuid
       respond_to do |f|
         f.html do
-          redirect_to(params[:return_to] || project_path(params[:uuid]))
+          if request.url.include?("/users/#{current_user.uuid}")
+            super
+          else
+            redirect_to(params[:return_to] || project_path(params[:uuid]))
+          end
         end
       end
     else
index 3fdbcd701961ad8c708fb21e90fb8d168173d993..57a5b74e93469c96232000d05bf83ac561b3aa66 100644 (file)
@@ -40,9 +40,7 @@
         </td>
       <% end %>
       <td>
-        <% if (current_user.is_admin and current_user.uuid != object.uuid) or !current_user.is_admin %>
-          <%= render :partial => "show_object_button", :locals => {object: object, size: 'xs'} %>
-        <% end %>
+        <%= render :partial => "show_object_button", :locals => {object: object, size: 'xs'} %>
       </td>
 
       <% object.attributes_for_display.each do |attr, attrvalue| %>
index 05c7f25185f92a4bba3aafc9d820f49bd0f9d26b..14d28d2adc7ac7b79436ede9b32bb32ac4c92371 100644 (file)
@@ -8,17 +8,20 @@ class SearchBoxTest < ActionDispatch::IntegrationTest
   # test the search box
   def verify_search_box user
     if user && user['is_active']
-      # let's search for a valid uuid
+      aproject_uuid = api_fixture('groups')['aproject']['uuid']
+      # let's search for aproject by uuid
       within('.navbar-fixed-top') do
         page.has_field?('search')
-        page.find_field('search').set user['uuid']
+        page.find_field('search').set aproject_uuid
         page.find('.glyphicon-search').click
       end
 
-      # we should now be in the user's home project as a result of search
-      assert_selector "#Data_collections[data-object-uuid='#{user['uuid']}']", "Expected to be in user page after search click"
+      # we should now be in aproject as a result of search
+      assert_selector 'a', text:'Data collections'
+      click_link 'Data collections'
+      assert_selector "#Data_collections[data-object-uuid='#{aproject_uuid}']", "Expected to be in user page after search click"
 
-      # let's search again for an invalid valid uuid
+      # let's search again for an invalid uuid
       within('.navbar-fixed-top') do
         search_for = String.new user['uuid']
         search_for[0]='1'
index 89554d3f87c6d65912b6fba3b439de7c1a3ef0ba..4615f846d7ee8170f94aa542d390385f85f6d429 100644 (file)
@@ -206,39 +206,36 @@ class UsersTest < ActionDispatch::IntegrationTest
   end
 
   [
-    ['admin', false],
-    ['active', true],
-  ].each do |username, expect_show_button|
-    test "login as #{username} and access show button #{expect_show_button}" do
+    'admin',
+    'active',
+  ].each do |username|
+    test "login as #{username} and access show button" do
       need_javascript
 
       user = api_fixture('users', username)
 
       visit page_with_token(username, '/users')
 
-      if expect_show_button
-        within('tr', text: user['uuid']) do
-          assert_text user['email']
-          assert_selector 'a', text: 'Show'
-          find('a', text: 'Show').click
-        end
-        assert_selector 'a', 'Data collections'
-      else
-        # no 'Show' button in the admin user's own row
-        within('tr', text: user['uuid']) do
-          assert_text user['email']
-          assert_no_selector 'a', text: 'Show'
-        end
-
-        # but the admin user can access 'Show' button for other users
-        active_user = api_fixture('users', 'active')
-        within('tr', text: active_user['uuid']) do
-          assert_text active_user['email']
-          assert_selector 'a', text: 'Show'
-          find('a', text: 'Show').click
-          assert_selector 'a', 'Attributes'
-        end
+      within('tr', text: user['uuid']) do
+        assert_text user['email']
+        assert_selector 'a', text: 'Show'
+        find('a', text: 'Show').click
       end
+      assert_selector 'a', text:'Attributes'
     end
   end
+
+  test "admin user can access another user page" do
+    need_javascript
+
+    visit page_with_token('admin', '/users')
+
+    active_user = api_fixture('users', 'active')
+    within('tr', text: active_user['uuid']) do
+      assert_text active_user['email']
+      assert_selector 'a', text: 'Show'
+      find('a', text: 'Show').click
+    end
+    assert_selector 'a', text:'Attributes'
+  end
 end