Browse Source

Set local authority before validation

pull/1439/head
Kat 3 years ago
parent
commit
ec303b7fa6
  1. 2
      app/models/location.rb
  2. 6
      spec/features/schemes_helpers.rb
  3. 6
      spec/features/schemes_spec.rb
  4. 4
      spec/requests/locations_controller_spec.rb

2
app/models/location.rb

@ -14,7 +14,7 @@ class Location < ApplicationRecord
has_paper_trail
before_save :lookup_postcode!, if: :postcode_changed?
before_validation :lookup_postcode!, if: :postcode_changed?
auto_strip_attributes :name

6
spec/features/schemes_helpers.rb

@ -64,7 +64,8 @@ module SchemesHelpers
click_button "Add a location"
fill_in with: "AA11AA"
click_button "Save and continue"
fill_in with: "Adur"
select "Adur"
click_button "Save and continue"
fill_in with: "Some name"
click_button "Save and continue"
fill_in with: 5
@ -84,7 +85,8 @@ module SchemesHelpers
click_button "Add a location"
fill_in with: "AA12AA"
click_button "Save and continue"
fill_in with: "Adur"
select "Adur"
click_button "Save and continue"
fill_in with: "Other name"
click_button "Save and continue"
fill_in with: 2

6
spec/features/schemes_spec.rb

@ -284,7 +284,8 @@ RSpec.describe "Schemes scheme Features" do
before do
fill_in with: "AA12AA"
click_button "Save and continue"
fill_in with: "Adur"
select "Adur"
click_button "Save and continue"
fill_in with: location_name
click_button "Save and continue"
fill_in with: 1
@ -904,7 +905,8 @@ RSpec.describe "Schemes scheme Features" do
before do
fill_in with: "AA12AA"
click_button "Save and continue"
fill_in with: "Adur"
select "Adur"
click_button "Save and continue"
fill_in with: location_name
click_button "Save and continue"
fill_in with: 1

4
spec/requests/locations_controller_spec.rb

@ -417,7 +417,7 @@ RSpec.describe LocationsController, type: :request do
it "redirects correctly when postcodes.io does return a local authority" do
follow_redirect!
expect(page).to have_content("What is the name of this location?")
expect(page).to have_content("What is the local authority")
end
end
@ -478,7 +478,7 @@ RSpec.describe LocationsController, type: :request do
it "redirects correctly when postcodes.io does return a local authority" do
follow_redirect!
expect(page).to have_content("What is the name of this location?")
expect(page).to have_content("What is the local authority")
end
end

Loading…
Cancel
Save