]> git.openstreetmap.org Git - rails.git/commitdiff
Show valid username in header when renaming
authorAnton Khorev <tony29@yandex.ru>
Sat, 5 Apr 2025 19:17:54 +0000 (22:17 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 5 Apr 2025 19:17:54 +0000 (22:17 +0300)
app/views/layouts/_header.html.erb
test/system/account_rename_test.rb [new file with mode: 0644]

index 69e323a997d6222a34e6f37d3ec46301cb35d29a..62691fbbfe04c95079bc0f071065e550621b76d1 100644 (file)
@@ -75,7 +75,7 @@
             <span class="badge count-number position-static m-1"><%= current_user.new_messages.size %></span>
           <% end %>
           <span class='username align-middle text-truncate' dir='auto'>
-            <%= current_user.display_name %>
+            <%= current_user.display_name_was %>
           </span>
         </button>
         <div class='dropdown-menu dropdown-menu-end'>
diff --git a/test/system/account_rename_test.rb b/test/system/account_rename_test.rb
new file mode 100644 (file)
index 0000000..a52fda6
--- /dev/null
@@ -0,0 +1,19 @@
+require "application_system_test_case"
+
+class AccountRenameTest < ApplicationSystemTestCase
+  test "renaming to invalid name shouldn't alter user button" do
+    user = create(:user, :display_name => "Valid User")
+    sign_in_as(user)
+
+    visit account_path
+
+    assert_button "Valid User"
+    assert_field "Display Name", :with => "Valid User"
+
+    fill_in "Display Name", :with => "x"
+    click_on "Save Changes"
+
+    assert_button "Valid User"
+    assert_field "Display Name", :with => "x"
+  end
+end