[ARVADOS] created: e8db6685b64c6853eb3c5d3ee27ba58168c3c8e8

git at public.curoverse.com git at public.curoverse.com
Wed Jun 17 14:14:33 EDT 2015


        at  e8db6685b64c6853eb3c5d3ee27ba58168c3c8e8 (commit)


commit e8db6685b64c6853eb3c5d3ee27ba58168c3c8e8
Author: radhika <radhika at curoverse.com>
Date:   Wed Jun 17 14:11:27 2015 -0400

    6234: In /users page, display the "Show" button to admin users as well; however, ensure redirection to
    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.

diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb
index e6ef6eb..cbe7e37 100644
--- a/apps/workbench/app/controllers/actions_controller.rb
+++ b/apps/workbench/app/controllers/actions_controller.rb
@@ -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.
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index ac3ea60..2f51365 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -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
diff --git a/apps/workbench/app/views/application/_show_recent.html.erb b/apps/workbench/app/views/application/_show_recent.html.erb
index 3fdbcd7..57a5b74 100644
--- a/apps/workbench/app/views/application/_show_recent.html.erb
+++ b/apps/workbench/app/views/application/_show_recent.html.erb
@@ -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| %>
diff --git a/apps/workbench/test/integration/search_box_test.rb b/apps/workbench/test/integration/search_box_test.rb
index 05c7f25..14d28d2 100644
--- a/apps/workbench/test/integration/search_box_test.rb
+++ b/apps/workbench/test/integration/search_box_test.rb
@@ -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'
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 89554d3..4615f84 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -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

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list