]> git.openstreetmap.org Git - rails.git/commitdiff
Fix redirect to terms path when not logged in
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 28 Jul 2021 15:36:13 +0000 (16:36 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 28 Jul 2021 15:36:13 +0000 (16:36 +0100)
This was missed during #3147 since it wasn't covered by a test.

app/controllers/users_controller.rb
test/controllers/users_controller_test.rb

index ec30eb4e7b14a3267b44dfcbd0386939c83009f9..727d8ee3faed139adce3edc3b0922bb81b94be0e 100644 (file)
@@ -30,7 +30,7 @@ class UsersController < ApplicationController
         # Already agreed to terms, so just show settings
         redirect_to :action => :account, :display_name => current_user.display_name
       elsif current_user.nil? && session[:new_user].nil?
-        redirect_to :action => :login, :referer => request.fullpath
+        redirect_to login_path(:referer => request.fullpath)
       end
     end
   end
index a73e48211f45dcc5a88533f8e43a19b3f8b8940a..10c5c3bee674e626585f7ba8632ff42455cc2afd 100644 (file)
@@ -414,6 +414,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to :action => :terms, :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
   end
 
+  def test_terms_not_logged_in
+    get user_terms_path
+
+    assert_redirected_to login_path(:referer => "/user/terms")
+  end
+
   def test_go_public
     user = create(:user, :data_public => false)
     session_for(user)