]> git.openstreetmap.org Git - rails.git/commitdiff
Link to all user's traces from successful import emails
authorAnton Khorev <tony29@yandex.ru>
Thu, 11 Jan 2024 14:48:40 +0000 (17:48 +0300)
committerAnton Khorev <tony29@yandex.ru>
Thu, 11 Jan 2024 14:48:40 +0000 (17:48 +0300)
app/mailers/user_mailer.rb
app/views/user_mailer/gpx_success.html.erb
config/locales/en.yml
test/mailers/user_mailer_test.rb

index 613c758792481af67da2f661bb3a707682eb25e0..d1ad60b2cad9c1d9aa2aa6ce150bd77999edc3ce 100644 (file)
@@ -50,6 +50,7 @@ class UserMailer < ApplicationMailer
       @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 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 8114c8b10b5a26b99744b147b436bd9bd1e27430..4420baa591e66fd0d8c532255ee992f3d3a55889 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 7857773eec2c1e1bb9bf107954150ee9dbe7532a..6df86c15e64b50aeb6ae391cf17a06558baac8bc 100644 (file)
@@ -18,6 +18,15 @@ class UserMailerTest < ActionMailer::TestCase
     assert_match(/one two three/, 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)