Skip to content

Commit

Permalink
Merge pull request #4392 from sanger/4310-y24-289-bug-exception
Browse files Browse the repository at this point in the history
 4310-y24-289-bug-exception
  • Loading branch information
wendyyang authored Oct 3, 2024
2 parents 2a5b8c6 + 7eb412f commit ed77842
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/barcode/format_handlers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,11 @@ class IbdResponse < BaseRegExBarcode
class Rvi < BaseRegExBarcode
self.format = /\A(?<prefix>RVI)-(?<number>[0-9]{6,})\z/
end

# add AkerBarcode class here as it could be called in
# Barcode::FormatHandlers.const_get in app/models/barcode.rb to avoid
# uninitialized constant Barcode::FormatHandlers::AkerBarcode (NameError)
class AkerBarcode < BaseRegExBarcode
self.format = /\A(?<prefix>Aker)-(?<number>[0-9]{2,})\z/
end
end
7 changes: 7 additions & 0 deletions spec/models/barcode/format_handlers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,12 @@ def self.it_has_an_invalid_barcode(barcode)
it_has_an_invalid_barcode 'IRVI-123456'
end

describe Barcode::FormatHandlers::AkerBarcode do
it_has_a_valid_barcode 'Aker-11', prefix: 'Aker', number: 11
it_has_an_invalid_barcode 'SQPD-12345678-234233890-WD'
it_has_an_invalid_barcode 'RVI123456'
it_has_an_invalid_barcode 'IRVI-123456'
end

# rubocop:enable RSpec/EmptyExampleGroup
end

0 comments on commit ed77842

Please sign in to comment.