]> git.openstreetmap.org Git - rails.git/blobdiff - test/jobs/trace_importer_job_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / jobs / trace_importer_job_test.rb
index e1ddcc9679cbd1161a366bffd20c6fdc6fbc4cb8..c6d44ecce22185fc3269db737261ba86625b3993 100644 (file)
@@ -52,6 +52,38 @@ class TraceImporterJobTest < ActiveJob::TestCase
     email = ActionMailer::Base.deliveries.last
     assert_equal trace.user.email, email.to[0]
     assert_match(/failure/, email.subject)
     email = ActionMailer::Base.deliveries.last
     assert_equal trace.user.email, email.to[0]
     assert_match(/failure/, email.subject)
+    assert_no_match(/Start tag expected/, email.text_part.body.to_s, "should not include parser error")
+    assert_match(%r{jobs/trace_importer_job\.rb}, email.text_part.body.to_s, "should include stack backtrace")
+
+    ActionMailer::Base.deliveries.clear
+  end
+
+  def test_parse_error_notification
+    trace = create(:trace, :inserted => false, :fixture => "jpg")
+    Rails.logger.silence do
+      TraceImporterJob.perform_now(trace)
+    end
+
+    email = ActionMailer::Base.deliveries.last
+    assert_equal trace.user.email, email.to[0]
+    assert_match(/failure/, email.subject)
+    assert_match(/Start tag expected/, email.text_part.body.to_s, "should include parser error")
+    assert_no_match(%r{jobs/trace_importer_job\.rb}, email.text_part.body.to_s, "should not include stack backtrace")
+
+    ActionMailer::Base.deliveries.clear
+  end
+
+  def test_gz_parse_error_notification
+    trace = create(:trace, :inserted => false, :fixture => "jpg.gz")
+    Rails.logger.silence do
+      TraceImporterJob.perform_now(trace)
+    end
+
+    email = ActionMailer::Base.deliveries.last
+    assert_equal trace.user.email, email.to[0]
+    assert_match(/failure/, email.subject)
+    assert_match(/Start tag expected/, email.text_part.body.to_s, "should include parser error")
+    assert_no_match(%r{jobs/trace_importer_job\.rb}, email.text_part.body.to_s, "should not include stack backtrace")
 
     ActionMailer::Base.deliveries.clear
   end
 
     ActionMailer::Base.deliveries.clear
   end