Skip to content

Commit

Permalink
Update local authority (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
martikat authored Nov 8, 2024
1 parent f66e2ea commit eda901b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
10 changes: 1 addition & 9 deletions app/forms/registration/local_authority_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ class LocalAuthorityForm < BaseForm
def save
return false unless valid?

user.update!(local_authority: local_authority_clean)
end

private

# @see Trainee:Authority#persisted_name
# @return [String] remove old name suffix
def local_authority_clean
local_authority.gsub(/\(.*?\)/, '').strip
user.update!(local_authority: local_authority)
end
end
end
8 changes: 0 additions & 8 deletions app/models/trainee/authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,5 @@ def self.all
def self.data
YAML.load_file Rails.root.join('data/local-authority.yml')
end

# @example
# Sanitise LA name changes before persisting
# "Cumberland (previously Cumbria)" => "Cumberland"
# @return [String]
def persisted_name
name.gsub(/\(.*?\)/, '').strip
end
end
end
4 changes: 2 additions & 2 deletions data/local-authority.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- name: County Durham
- name: Coventry
- name: Croydon
- name: Cumberland (previously Cumbria)
- name: Cumberland
- name: Darlington
- name: Derby
- name: Derbyshire
Expand Down Expand Up @@ -143,7 +143,7 @@
- name: West Northamptonshire
- name: West Sussex
- name: Westminster
- name: Westmorland and Furness (previously Cumbria)
- name: Westmorland and Furness
- name: Wigan
- name: Wiltshire
- name: Windsor and Maidenhead
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/registration/local_authorities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

context 'with available option' do
let(:local_authority) { Trainee::Authority.all.sample.persisted_name }
let(:local_authority) { Trainee::Authority.all.sample.name }

it 'updates user' do
expect { update_user }.to change { user.reload.local_authority }.to(local_authority)
Expand Down

0 comments on commit eda901b

Please sign in to comment.