Skip to content

Commit

Permalink
Allow up to 7 digits for FCA numbers
Browse files Browse the repository at this point in the history
FCA now has entries listed with up to 7 digits for identification. We
only allowed 6 digits precisely before so this change permits FCA
numbers between 6-7 digits long.

A new run of FCA data will need to run first to backfill the reference
data as prior to this change we were quietly dropping any reference data
identified by FCA numbers not precisely 6 digits long.
  • Loading branch information
benlovell committed Jul 24, 2024
1 parent 550fc72 commit 378df2a
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 378df2a

Please sign in to comment.