]> git.openstreetmap.org Git - rails.git/commitdiff
Preserve anchor in referer link inside warning
authorAnton Khorev <tony29@yandex.ru>
Sat, 26 Apr 2025 17:54:50 +0000 (20:54 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 27 Apr 2025 03:50:23 +0000 (06:50 +0300)
app/assets/javascripts/login.js
app/views/sessions/new.html.erb
test/system/user_login_test.rb

index 8297944f3720ff769043899715adcd655d765b80..c0d9fe57bd4139b1c0e74605b11798b1efc842b1 100644 (file)
@@ -2,5 +2,6 @@ $(function () {
   // Preserve location hash in referer
   if (location.hash) {
     $("#referer").val($("#referer").val() + location.hash);
+    $("#referer_link").prop("hash", location.hash);
   }
 });
index 391a96291e26317318a11f9f74ecd7870616fd9c..ec4e256dfce0d30d672e5697633161daf6a54ebb 100644 (file)
@@ -37,7 +37,7 @@
         <%= t ".access_another_page" %>
       </p>
       <p class="text-center">
-        <%= link_to t(".visit_referring_page"), @safe_referer, :class => "btn btn-warning" %>
+        <%= link_to t(".visit_referring_page"), @safe_referer, :id => "referer_link", :class => "btn btn-warning" %>
       </p>
     <% end %>
   </div>
index 9800752a67aaa133655c11c8bb6c5954f8e8caef..ce17d04ea0bd3884e5ac5c1112a902088a3fb6eb 100644 (file)
@@ -25,7 +25,7 @@ class UserLoginTest < ApplicationSystemTestCase
     user1 = create(:user, :display_name => "First User")
     sign_in_as(user1)
 
-    visit login_path(:referer => about_path)
+    visit login_path(:referer => copyright_path, :anchor => "trademarks")
 
     assert_button "First User"
     within_content_body do
@@ -35,7 +35,8 @@ class UserLoginTest < ApplicationSystemTestCase
       click_on "Visit referring page"
     end
 
-    assert_current_path about_path
+    assert_current_path copyright_path
+    assert_equal "#trademarks", execute_script("return location.hash")
   end
 
   test "Only show safe referer links inside warnings" do