]> git.openstreetmap.org Git - rails.git/blob - test/mailers/user_mailer_test.rb
1e3d9cc743f0c1f183a06439a8146ef1f0d1dc5a
[rails.git] / test / mailers / user_mailer_test.rb
1 require "test_helper"
2
3 class UserMailerTest < ActionMailer::TestCase
4   def test_html_layout_is_used
5     email = UserMailer.message_notification(create(:message))
6
7     assert_match(/<html lang=/, email.html_part.body.to_s)
8   end
9
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")
15     end
16     email = UserMailer.gpx_success(trace, 100)
17
18     assert_match(/one two three/, email.html_part.body.to_s)
19   end
20
21   def test_gpx_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)
25
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
28   end
29
30   def test_html_encoding
31     user = create(:user, :display_name => "Jack & Jill <br>")
32     message = create(:message, :sender => user)
33     email = UserMailer.message_notification(message)
34
35     assert_match("Jack & Jill <br>", email.text_part.body.to_s)
36     assert_match("Jack &amp; Jill &lt;br&gt;", email.html_part.body.to_s)
37   end
38 end