]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/4472'
authorTom Hughes <tom@compton.nu>
Fri, 12 Jan 2024 18:03:36 +0000 (18:03 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 12 Jan 2024 18:03:36 +0000 (18:03 +0000)
app/mailers/user_mailer.rb
app/views/user_mailer/_gpx_description.html.erb
app/views/user_mailer/gpx_success.html.erb
config/locales/en.yml
test/mailers/user_mailer_test.rb

index 8ca186aad92141dcc235c9d7f1b634b3e93c7c1d..d1ad60b2cad9c1d9aa2aa6ce150bd77999edc3ce 100644 (file)
@@ -44,11 +44,13 @@ 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
       @trace_tags = trace.tags
       @possible_points = possible_points
+      @my_traces_url = url_for(:controller => "traces", :action => "mine")
 
       mail :to => trace.user.email,
            :subject => t(".subject")
index 50fcd69600ff05d966de48f29318df88619113ae..85b4c7cae1c0e9f198a69d75128e722f42a09dac 100644 (file)
@@ -1,7 +1,8 @@
 <% trace_name = tag.strong(@trace_name) %>
+<% trace_name = link_to(trace_name, @trace_url) if @trace_url %>
 <% trace_description = tag.em(@trace_description) %>
 <% if @trace_tags.length > 0 %>
-  <% tags = @trace_tags.map(&:tag).join(" ") %>
+  <% tags = safe_join @trace_tags.map { |trace_tag| tag.em trace_tag.tag }, ", " %>
   <%= t ".description_with_tags_html", :trace_name => trace_name, :trace_description => trace_description, :tags => tags %>
 <% else %>
   <%= t ".description_with_no_tags_html", :trace_name => trace_name, :trace_description => trace_description %>
index ad60408bd8c2d68663a7d39ce37e0bc1ab58d2d1..4354db20afa708ca0e8753577e54bb83acf3cabd 100644 (file)
@@ -4,3 +4,7 @@
   <%= render :partial => "gpx_description" %>
   <%= t(".loaded", :trace_points => @trace_points, :count => @possible_points) %>
 </p>
+
+<p>
+  <%= t ".all_your_traces_html", :url => link_to(@my_traces_url, @my_traces_url) %>
+</p>
index c9f319dda4544d4ecbcac86ac3d6e58b47b87859..3026bb3aa462a0821180f72800b9d79d52128ced 100644 (file)
@@ -1590,6 +1590,7 @@ en:
       loaded:
         one: "loaded successfully with %{trace_points} out of a possible %{count} point."
         other: "loaded successfully with %{trace_points} out of a possible %{count} points."
+      all_your_traces_html: "All your successfully uploaded GPX traces can be found at %{url}."
       subject: "[OpenStreetMap] GPX Import success"
     signup_confirm:
       subject: "[OpenStreetMap] Welcome to OpenStreetMap"
index 537bb9d0ddf60ec4220007d56d3c6986f524be7b..751adcd82dc361583bf4e8ea7ca4ad8a8d3ac8f9 100644 (file)
@@ -15,7 +15,34 @@ class UserMailerTest < ActionMailer::TestCase
     end
     email = UserMailer.gpx_success(trace, 100)
 
-    assert_match(/one two three/, email.html_part.body.to_s)
+    assert_match("<em>one</em>, <em>two</em>, <em>three</em>", email.html_part.body.to_s)
+  end
+
+  def test_gpx_success_all_traces_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.url_for(:controller => "traces", :action => "mine", :host => Settings.server_url, :protocol => Settings.server_protocol)
+    assert_select body, "a[href='#{url}']"
+  end
+
+  def test_gpx_success_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_gpx_failure_no_trace_link
+    trace = create(:trace)
+    email = UserMailer.gpx_failure(trace, "some error")
+    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}']", :count => 0
   end
 
   def test_html_encoding