Fix email messages link in admin's user page (#11595)

This commit is contained in:
rhymes 2020-11-24 16:35:14 +01:00 committed by GitHub
parent e2f33a37b7
commit d49c00aa84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -25,7 +25,10 @@
<h3>Recent Emails</h3>
<div class="list-group-flush">
<% @user.email_messages.order(sent_at: :desc).limit(50).each do |email| %>
<a href="/admin/email_messages/<%= email.id %>" class="list-group-item list-group-item-action">
<a href="<%= resource_admin_email_message_path(email.id) %>"
class="list-group-item list-group-item-action"
rel="noopener noreferer"
target="_blank">
<%= email.subject %>
<em> - <%= email.sent_at&.strftime("%b %e '%y") %></em>
</a>

View file

@ -44,6 +44,15 @@ RSpec.describe "admin/users", type: :request do
expect(response.body).to include("Current Roles")
end
end
context "when a user has been sent an email" do
it "renders a link to the user email on the Resource Admin" do
email = create(:email_message, user: user, to: user.email)
get admin_user_path(user.id)
expect(response.body).to include(resource_admin_email_message_path(email.id))
end
end
end
describe "GET /admin/users/:id/edit" do