]> git.openstreetmap.org Git - rails.git/commitdiff
Simplify remaining link_to ... user_path in views
authorAnton Khorev <tony29@yandex.ru>
Thu, 21 Mar 2024 15:07:56 +0000 (18:07 +0300)
committerAnton Khorev <tony29@yandex.ru>
Thu, 21 Mar 2024 15:07:56 +0000 (18:07 +0300)
12 files changed:
app/views/changesets/history.html.erb
app/views/layouts/_header.html.erb
app/views/notes/index.html.erb
app/views/oauth/authorize.html.erb
app/views/profiles/edit.html.erb
app/views/redactions/show.html.erb
app/views/user_mutes/index.html.erb
app/views/users/_user.html.erb
test/controllers/changesets_controller_test.rb
test/controllers/notes_controller_test.rb
test/controllers/redactions_controller_test.rb
test/controllers/user_mutes_controller_test.rb

index a9970e652dae24da2542bf32fddfc9e15a2f9035..a536677b08b727fc304414ba8b5571c29e2618b7 100644 (file)
@@ -6,7 +6,7 @@
 
 <% set_title(changeset_index_title(params, current_user))
    @heading = if params[:display_name]
-                t("changesets.index.title_user_link_html", :user_link => link_to(params[:display_name], user_path(:display_name => params[:display_name])))
+                t("changesets.index.title_user_link_html", :user_link => link_to(params[:display_name], user_path(params[:display_name])))
               else
                 @title
               end %>
index e9ded0f75c7f68cda1aec81000512bbf5e9c4d01..97be3f7b8c96b78774ed2e5fd09dc3608ee3744c 100644 (file)
@@ -96,7 +96,7 @@
             <%= t("users.show.my messages") %>
             <span class='badge count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
           <% end %>
-          <%= link_to t("users.show.my profile"), user_path(current_user), :class => "dropdown-item" %>
+          <%= link_to t("users.show.my profile"), current_user, :class => "dropdown-item" %>
           <%= link_to t("users.show.my settings"), edit_account_path, :class => "dropdown-item" %>
           <%= link_to t("users.show.my_preferences"), preferences_path, :class => "dropdown-item" %>
           <div class="dropdown-divider"></div>
index ef625163400ceac7c75eb9c903fffa30c4c0fc95..d93978480e8bfe2b4d98094d88640a73d58514b0 100644 (file)
@@ -1,7 +1,7 @@
 <% content_for :heading do %>
   <h1><%= t ".heading", :user => @user.display_name %></h1>
   <p><%= t ".subheading_html",
-           :user => link_to(@user.display_name, user_path(@user)),
+           :user => link_to(@user.display_name, @user),
            :submitted => tag.span(t(".subheading_submitted"), :class => "px-2 py-1 bg-primary bg-opacity-25"),
            :commented => tag.span(t(".subheading_commented"), :class => "px-2 py-1 bg-white") %></p>
 <% end %>
index 8576ea3ab77c7cdbf761d8167f12f71d7a01896b..b8fe11f75b1ffdbdc7bab0e02d006e3bd73982e4 100644 (file)
@@ -2,7 +2,7 @@
   <h1><%= t ".title" %></h1>
 <% end %>
 
-<p><%= t(".request_access_html", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, user_path(current_user))) %></p>
+<p><%= t(".request_access_html", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, current_user)) %></p>
 
 <%= bootstrap_form_tag do |f| %>
   <%= f.hidden_field :oauth_token, :value => @token.token %>
index b207e72e2e6f979df549e0987aa0b73957e63731..47282d5a22cbee0622336649fcdf9ef5a0c3567d 100644 (file)
@@ -60,5 +60,5 @@
   </fieldset>
 
   <%= f.primary t(".save") %>
-    <%= link_to t(".cancel"), user_path(current_user), :class => "btn btn-link" %>
+    <%= link_to t(".cancel"), current_user, :class => "btn btn-link" %>
 <% end %>
index 22d17cd5d5c3ad503e17be5cc3724456f2e834e5..5b9749a5113b7f2c3caa686b98c84b7b3103c75a 100644 (file)
@@ -5,7 +5,7 @@
 
 <p>
   <b><%= t ".user" %></b>
-  <%= link_to(@redaction.user.display_name, user_path(@redaction.user)) %>
+  <%= link_to @redaction.user.display_name, @redaction.user %>
 </p>
 <div class="richtext text-break">
   <b><%= t ".description" %></b>
index cf9e7ed6bc4336b74ae4fa7f1884e376b116f0b5..8779a4bba011d014a956507214b3667a68303e1a 100644 (file)
@@ -25,7 +25,7 @@
         <tr>
           <td>
             <%= user_thumbnail_tiny user %>
-            <%= link_to user.display_name, user_path(user) %>
+            <%= link_to user.display_name, user %>
           </td>
           <td class="text-nowrap text-end">
             <%= link_to t(".table.tbody.unmute"), user_mute_path(user), :method => :delete, :class => "btn btn-sm btn-primary" %>
index e419aed1d43d2b22d7cde109f4fef91d45ab2391..ef50ccaf2fb4bffa27c19ce8950fbbd6b7e13209 100644 (file)
@@ -6,12 +6,12 @@
     <p>
       <% if user.creation_ip %>
         <%= t "users.index.summary_html",
-              :name => link_to(user.display_name, user_path(user)),
+              :name => link_to(user.display_name, user),
               :ip_address => link_to(user.creation_ip, :ip => user.creation_ip),
               :date => l(user.created_at, :format => :friendly) %>
       <% else %>
         <%= t "users.index.summary_no_ip_html",
-              :name => link_to(user.display_name, user_path(user)),
+              :name => link_to(user.display_name, user),
               :date => l(user.created_at, :format => :friendly) %>
       <% end %>
     </p>
index 32a4e4f70545eaddb275a3055fa40f63b2251cd7..1fd9de2e810fb8a9735731055213fecd5148f967 100644 (file)
@@ -133,7 +133,9 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "history"
     assert_template :layout => "map"
-    assert_select "h2", :text => "Changesets by #{user.display_name}", :count => 1
+    assert_select "h2", :text => "Changesets by #{user.display_name}", :count => 1 do
+      assert_select "a[href=?]", user_path(user)
+    end
     assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do
       assert_select "[href=?]", "http://www.example.com/user/#{ERB::Util.url_encode(user.display_name)}/history/feed"
     end
index 8f764a3f249b58bcad66fa7baa70a3735dff6870..99886c80fd0e66fe71972a90e1350c6ceb3d6ffc 100644 (file)
@@ -42,10 +42,12 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
 
     get user_notes_path(first_user)
     assert_response :success
+    assert_select ".content-heading a[href='#{user_path first_user}']", :text => first_user.display_name
     assert_select "table.note_list tbody tr", :count => 1
 
     get user_notes_path(second_user)
     assert_response :success
+    assert_select ".content-heading a[href='#{user_path second_user}']", :text => second_user.display_name
     assert_select "table.note_list tbody tr", :count => 1
 
     get user_notes_path("non-existent")
index 002e483fea3262e6e45c9f2f1be129f6079ee8fa..5ca72fe478263bde3b0234638990f1fc13ad8d92 100644 (file)
@@ -45,6 +45,15 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest
     end
   end
 
+  def test_show
+    redaction = create(:redaction, :title => "tested-redaction")
+
+    get redaction_path(redaction)
+    assert_response :success
+    assert_dom "h1", :text => /tested-redaction/
+    assert_dom "a[href='#{user_path redaction.user}']", :text => redaction.user.display_name
+  end
+
   def test_new
     get new_redaction_path
     assert_redirected_to login_path(:referer => new_redaction_path)
index cc22faaaa1dfc3ca8c175fd3c5eede9cdf58d673..2e98dc819866a05512d0f12a78a4905fb9e9af97 100644 (file)
@@ -18,11 +18,13 @@ class UserMutesControllerTest < ActionDispatch::IntegrationTest
 
   def test_index
     user = create(:user)
-    user.mutes.create(:subject => create(:user))
+    muted_user = create(:user)
+    user.mutes.create(:subject => muted_user)
     session_for(user)
 
     get user_mutes_path
     assert_match "You have muted 1 User", @response.body
+    assert_dom "tr a[href='#{user_path muted_user}']", :text => muted_user.display_name
   end
 
   def test_create