Skip to content

Commit

Permalink
Normalize provider names
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric committed Nov 20, 2024
1 parent b58b4be commit fd65fd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Provider < ApplicationRecord
primary_key: :provider_code,
inverse_of: :accrediting_provider

normalizes :provider_name, with: ->(value) { value.gsub(/\s+/, ' ').strip }

def accredited_providers
recruitment_cycle.providers.where(provider_code: accredited_provider_codes)
end
Expand Down
4 changes: 4 additions & 0 deletions spec/models/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
end
end

describe 'normalizations' do
it { is_expected.to normalize(:provider_name).from(' ACME SCITT ').to('ACME SCITT') }
end

describe 'organisation' do
it 'returns the only organisation a provider has' do
expect(subject.organisation).to eq subject.organisations.first
Expand Down

0 comments on commit fd65fd0

Please sign in to comment.