Skip to content

Commit

Permalink
Merge pull request #639 from moneyadviceservice/fca-number-lengths
Browse files Browse the repository at this point in the history
Allow up to 7 digits for FCA numbers
  • Loading branch information
benlovell authored Jul 24, 2024
2 parents 550fc72 + 378df2a commit e6af5fd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/lookup/firm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Firm < ApplicationRecord
has_many :subsidiaries, primary_key: :fca_number, foreign_key: :fca_number

validates :fca_number,
length: { is: 6 },
length: { in: 6..7 },
numericality: { only_integer: true }

def subsidiaries?
Expand Down
2 changes: 1 addition & 1 deletion app/models/lookup/subsidiary.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Lookup
class Subsidiary < ApplicationRecord
validates :fca_number,
length: { is: 6 },
length: { in: 6..7 },
numericality: { only_integer: true }

def self.table_name
Expand Down
2 changes: 1 addition & 1 deletion app/models/principal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Principal < ApplicationRecord
validates :fca_number,
presence: true,
uniqueness: true,
length: { is: 6 },
length: { in: 6..7 },
numericality: { only_integer: true }

validates :email_address,
Expand Down
5 changes: 3 additions & 2 deletions spec/models/lookup/firm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
expect(described_class.new(fca_number: '123A45')).to_not be_valid
end

it 'accepts only 6 digits' do
expect(described_class.new(fca_number: 1_234_567)).to_not be_valid
it 'accepts between 6 and 7 digits' do
expect(described_class.new(fca_number: 1_234_567)).to be_valid
expect(described_class.new(fca_number: 1_234_567_8)).to_not be_valid
end
end
end
Expand Down

0 comments on commit e6af5fd

Please sign in to comment.