Merge remote-tracking branch 'upstream/pull/5226'
This commit is contained in:
commit
0bf56cd3ce
5 changed files with 37 additions and 1 deletions
|
@ -10,6 +10,10 @@ class TraceImporterJob < ApplicationJob
|
|||
UserMailer.gpx_failure(trace, "0 points parsed ok. Do they all have lat,lng,alt,timestamp?").deliver
|
||||
trace.destroy
|
||||
end
|
||||
rescue XML::Error => e
|
||||
logger.info e.to_s
|
||||
UserMailer.gpx_failure(trace, e).deliver
|
||||
trace.destroy
|
||||
rescue StandardError => e
|
||||
logger.info e.to_s
|
||||
e.backtrace.each { |l| logger.info l }
|
||||
|
|
|
@ -57,7 +57,7 @@ module GPX
|
|||
when "application/x-bzip" then io = Bzip2::FFI::Reader.open(@file)
|
||||
end
|
||||
|
||||
parse_file(XML::Reader.io(io), &block)
|
||||
parse_file(XML::Reader.io(io, :options => XML::Parser::Options::NOERROR), &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
BIN
test/gpx/fixtures/jpg.gpx
Normal file
BIN
test/gpx/fixtures/jpg.gpx
Normal file
Binary file not shown.
After Width: | Height: | Size: 287 B |
BIN
test/gpx/fixtures/jpg.gz.gpx
Normal file
BIN
test/gpx/fixtures/jpg.gz.gpx
Normal file
Binary file not shown.
|
@ -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)
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue