From: Anton Khorev Date: Thu, 21 Mar 2024 15:07:56 +0000 (+0300) Subject: Simplify remaining link_to ... user_path in views X-Git-Tag: live~700^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/b8f5a495f21b8d3572ed6184121d845b9ed1ec4c Simplify remaining link_to ... user_path in views --- diff --git a/app/views/changesets/history.html.erb b/app/views/changesets/history.html.erb index a9970e652..a536677b0 100644 --- a/app/views/changesets/history.html.erb +++ b/app/views/changesets/history.html.erb @@ -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 %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index e9ded0f75..97be3f7b8 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -96,7 +96,7 @@ <%= t("users.show.my messages") %> <%= number_with_delimiter(current_user.new_messages.size) %> <% 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" %> diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index ef6251634..d93978480 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -1,7 +1,7 @@ <% content_for :heading do %>

<%= t ".heading", :user => @user.display_name %>

<%= 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") %>

<% end %> diff --git a/app/views/oauth/authorize.html.erb b/app/views/oauth/authorize.html.erb index 8576ea3ab..b8fe11f75 100644 --- a/app/views/oauth/authorize.html.erb +++ b/app/views/oauth/authorize.html.erb @@ -2,7 +2,7 @@

<%= t ".title" %>

<% end %> -

<%= 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))) %>

+

<%= 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)) %>

<%= bootstrap_form_tag do |f| %> <%= f.hidden_field :oauth_token, :value => @token.token %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb index b207e72e2..47282d5a2 100644 --- a/app/views/profiles/edit.html.erb +++ b/app/views/profiles/edit.html.erb @@ -60,5 +60,5 @@ <%= 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 %> diff --git a/app/views/redactions/show.html.erb b/app/views/redactions/show.html.erb index 22d17cd5d..5b9749a51 100644 --- a/app/views/redactions/show.html.erb +++ b/app/views/redactions/show.html.erb @@ -5,7 +5,7 @@

<%= t ".user" %> - <%= link_to(@redaction.user.display_name, user_path(@redaction.user)) %> + <%= link_to @redaction.user.display_name, @redaction.user %>

<%= t ".description" %> diff --git a/app/views/user_mutes/index.html.erb b/app/views/user_mutes/index.html.erb index cf9e7ed6b..8779a4bba 100644 --- a/app/views/user_mutes/index.html.erb +++ b/app/views/user_mutes/index.html.erb @@ -25,7 +25,7 @@ <%= user_thumbnail_tiny user %> - <%= link_to user.display_name, user_path(user) %> + <%= link_to user.display_name, user %> <%= link_to t(".table.tbody.unmute"), user_mute_path(user), :method => :delete, :class => "btn btn-sm btn-primary" %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index e419aed1d..ef50ccaf2 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -6,12 +6,12 @@

<% 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 %>

diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index 32a4e4f70..1fd9de2e8 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -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 diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 8f764a3f2..99886c80f 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -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") diff --git a/test/controllers/redactions_controller_test.rb b/test/controllers/redactions_controller_test.rb index 002e483fe..5ca72fe47 100644 --- a/test/controllers/redactions_controller_test.rb +++ b/test/controllers/redactions_controller_test.rb @@ -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) diff --git a/test/controllers/user_mutes_controller_test.rb b/test/controllers/user_mutes_controller_test.rb index cc22faaaa..2e98dc819 100644 --- a/test/controllers/user_mutes_controller_test.rb +++ b/test/controllers/user_mutes_controller_test.rb @@ -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