Simplify remaining link_to ... user_path in views

This commit is contained in:
Anton Khorev 2024-03-21 18:07:56 +03:00
parent 0dc86d6cd4
commit b8f5a495f2
12 changed files with 26 additions and 11 deletions

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

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

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

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

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

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

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

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

View 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

View 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")

View 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)

View 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