[ARVADOS] created: 0fb40a0d01d6e6500ea6f87e45476daab511a1f2

git at public.curoverse.com git at public.curoverse.com
Mon Nov 9 14:44:48 EST 2015


        at  0fb40a0d01d6e6500ea6f87e45476daab511a1f2 (commit)


commit 0fb40a0d01d6e6500ea6f87e45476daab511a1f2
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Nov 9 12:02:25 2015 -0500

    6846: Workbench navigation bar login returns user to the same page.

diff --git a/apps/workbench/app/views/layouts/body.html.erb b/apps/workbench/app/views/layouts/body.html.erb
index 22ccc2f..927bbda 100644
--- a/apps/workbench/app/views/layouts/body.html.erb
+++ b/apps/workbench/app/views/layouts/body.html.erb
@@ -138,10 +138,10 @@
               <li><%= link_to 'Browse public projects', "/projects/public" %></li>
             <% end %>
             <li class="dropdown hover-dropdown login-menu">
-              <a href="<%= arvados_api_client.arvados_login_url(return_to: root_url) %>">Log in</a>
+              <a href="<%= arvados_api_client.arvados_login_url(return_to: request.fullpath) %>">Log in</a>
               <ul class="dropdown-menu">
                 <li>
-                  <a href="<%= arvados_api_client.arvados_login_url(return_to: root_url) %>">
+                  <a href="<%= arvados_api_client.arvados_login_url(return_to: request.fullpath) %>">
                     <span class="fa fa-lg fa-sign-in"></span>
                     <p style="margin-left: 1.6em; margin-top: -1.35em; margin-bottom: 0em; margin-right: 0.5em;">Log in or register with<br/>any Google account</p>
                   </a>
diff --git a/apps/workbench/test/controllers/application_controller_test.rb b/apps/workbench/test/controllers/application_controller_test.rb
index 15d52da..001bafd 100644
--- a/apps/workbench/test/controllers/application_controller_test.rb
+++ b/apps/workbench/test/controllers/application_controller_test.rb
@@ -334,6 +334,23 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_response 404
   end
 
+  [".navbar .login-menu a",
+   ".navbar .login-menu .dropdown-menu a"
+  ].each do |css_selector|
+    test "login link at #{css_selector.inspect} includes return_to param" do
+      # Without an anonymous token, we're immediately redirected to login.
+      Rails.configuration.anonymous_user_token =
+        api_fixture("api_client_authorizations", "anonymous", "api_token")
+      @controller = ProjectsController.new
+      test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz"
+      get(:show, {id: test_uuid})
+      login_link = css_select(css_selector).first
+      assert_not_nil(login_link, "failed to select login link")
+      assert_match(/[\?&]return_to=[^&]*\/projects\/#{test_uuid}(&|$)/,
+                   URI.unescape(login_link.attributes["href"]))
+    end
+  end
+
   test "Workbench returns 4xx when API server is unreachable" do
     # We're really testing ApplicationController's render_exception.
     # Our primary concern is that it doesn't raise an error and

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list