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")
<% 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 %>
<%= 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>
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"
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