Skip to content

Commit

Permalink
Check validity of ean13 code before adding pseudo_fachinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Mar 5, 2014
1 parent 07f307f commit 04d3894
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugin/medical_products.rb
Expand Up @@ -54,7 +54,7 @@ def update
full_info = paragraph.text.gsub("\n","").gsub(/\s+/, ' ').gsub(' ,',',')
m = full_info.match(/^(\d{13})/);
next unless m
ean = m[1]
ean = Ean13.new(m[1])
number = ean[2..2+6] # 7 digits
packNr = ean[9..11] # 3 digits
m3 = full_info.match(/^(\d{13})[\s,][\d\s]*([^\d,]+)/);
Expand Down
Binary file added test/data/docx/errors/invalid_ean13.docx
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_plugin/medical_products.rb
Expand Up @@ -215,5 +215,11 @@ def test_update_medical_product_french
assert_equal(2, @app.registrations.first.packages.size, 'we must have exactly two packages')
assert_equal(nil, @app.registrations.first.packages.first.commercial_forms.first)
end
def test_update_invalid_ean
fileName = File.join('errors', 'invalid_ean13.docx')
options = {:files => [ fileName ], :lang => 'de' }
@plugin = ODDB::MedicalProductPlugin.new(@app, options)
assert_raises(SBSM::InvalidDataError) {@plugin.update()}
end
end
end

0 comments on commit 04d3894

Please sign in to comment.