3 class UserMailerTest < ActionMailer::TestCase
4 def test_html_layout_is_used
5 email = UserMailer.message_notification(create(:message))
7 assert_match(/<html lang=/, email.html_part.body.to_s)
10 def test_gpx_description_tags
11 trace = create(:trace) do |t|
12 create(:tracetag, :trace => t, :tag => "one")
13 create(:tracetag, :trace => t, :tag => "two")
14 create(:tracetag, :trace => t, :tag => "three")
16 email = UserMailer.gpx_success(trace, 100)
18 assert_match(/one two three/, email.html_part.body.to_s)
21 def test_gpx_success_trace_link
22 trace = create(:trace)
23 email = UserMailer.gpx_success(trace, 100)
24 body = Rails::Dom::Testing.html_document_fragment.parse(email.html_part.body)
26 url = Rails.application.routes.url_helpers.show_trace_url(trace.user, trace, :host => Settings.server_url, :protocol => Settings.server_protocol)
27 assert_select body, "a[href='#{url}']", :text => trace.name
30 def test_gpx_failure_no_trace_link
31 trace = create(:trace)
32 email = UserMailer.gpx_failure(trace, "some error")
33 body = Rails::Dom::Testing.html_document_fragment.parse(email.html_part.body)
35 url = Rails.application.routes.url_helpers.show_trace_url(trace.user, trace, :host => Settings.server_url, :protocol => Settings.server_protocol)
36 assert_select body, "a[href='#{url}']", :count => 0
39 def test_html_encoding
40 user = create(:user, :display_name => "Jack & Jill <br>")
41 message = create(:message, :sender => user)
42 email = UserMailer.message_notification(message)
44 assert_match("Jack & Jill <br>", email.text_part.body.to_s)
45 assert_match("Jack & Jill <br>", email.html_part.body.to_s)