From: Anton Khorev Date: Thu, 11 Jan 2024 13:49:01 +0000 (+0300) Subject: Link to trace pages from successful import emails X-Git-Tag: live~851^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/02aa14ffea55ef5ed4c488588a37d27bbf60f95b Link to trace pages from successful import emails --- diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 8ca186aad..613c75879 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -44,6 +44,7 @@ class UserMailer < ApplicationMailer def gpx_success(trace, possible_points) with_recipient_locale trace.user do @to_user = trace.user.display_name + @trace_url = show_trace_url(trace.user, trace) @trace_name = trace.name @trace_points = trace.size @trace_description = trace.description diff --git a/app/views/user_mailer/_gpx_description.html.erb b/app/views/user_mailer/_gpx_description.html.erb index 50fcd6960..eb9d5e102 100644 --- a/app/views/user_mailer/_gpx_description.html.erb +++ b/app/views/user_mailer/_gpx_description.html.erb @@ -1,4 +1,4 @@ -<% trace_name = tag.strong(@trace_name) %> +<% trace_name = link_to tag.strong(@trace_name), @trace_url %> <% trace_description = tag.em(@trace_description) %> <% if @trace_tags.length > 0 %> <% tags = @trace_tags.map(&:tag).join(" ") %> diff --git a/test/mailers/user_mailer_test.rb b/test/mailers/user_mailer_test.rb index 537bb9d0d..1e3d9cc74 100644 --- a/test/mailers/user_mailer_test.rb +++ b/test/mailers/user_mailer_test.rb @@ -18,6 +18,15 @@ class UserMailerTest < ActionMailer::TestCase assert_match(/one two three/, email.html_part.body.to_s) end + def test_gpx_trace_link + trace = create(:trace) + email = UserMailer.gpx_success(trace, 100) + body = Rails::Dom::Testing.html_document_fragment.parse(email.html_part.body) + + url = Rails.application.routes.url_helpers.show_trace_url(trace.user, trace, :host => Settings.server_url, :protocol => Settings.server_protocol) + assert_select body, "a[href='#{url}']", :text => trace.name + end + def test_html_encoding user = create(:user, :display_name => "Jack & Jill
") message = create(:message, :sender => user)