From 6d0d40fb2217af0f1eb1b3b4a22434808cfbfe9d Mon Sep 17 00:00:00 2001
From: Ted-U <92022120+Ted-U@users.noreply.github.com>
Date: Tue, 2 Aug 2022 15:51:22 +0100
Subject: [PATCH] CLDC-1381-Postcode-display-formatting (#781)
---
app/models/case_log.rb | 19 +++++++++++++++++--
app/models/location.rb | 10 +++++++++-
app/models/scheme.rb | 4 ++--
.../imports/case_logs_import_service.rb | 4 ++--
.../form/conditional_questions_spec.rb | 2 +-
spec/features/schemes_helpers.rb | 4 ++--
spec/features/schemes_spec.rb | 10 +++++-----
spec/fixtures/exports/general_needs_log.csv | 2 +-
spec/fixtures/exports/general_needs_log.xml | 4 ++--
.../exports/supported_housing_logs.xml | 4 ++--
spec/fixtures/files/case_logs_download.csv | 2 +-
spec/models/case_log_spec.rb | 14 +++++++-------
spec/models/location_spec.rb | 4 ++--
spec/requests/case_logs_controller_spec.rb | 6 +++---
spec/requests/locations_controller_spec.rb | 16 ++++++++--------
15 files changed, 64 insertions(+), 41 deletions(-)
diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index d4e1286e8..0e9d550e0 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -8,7 +8,6 @@ class CaseLogValidator < ActiveModel::Validator
include Validations::TenancyValidations
include Validations::DateValidations
include Validations::LocalAuthorityValidations
-
def validate(record)
validation_methods = public_methods.select { |method| method.starts_with?("validate_") }
validation_methods.each { |meth| public_send(meth, record) }
@@ -57,7 +56,7 @@ class CaseLog < ApplicationRecord
scope :filter_by_id, ->(id) { where(id:) }
scope :filter_by_tenant_code, ->(tenant_code) { where("tenancycode ILIKE ?", "%#{tenant_code}%") }
scope :filter_by_propcode, ->(propcode) { where("propcode ILIKE ?", "%#{propcode}%") }
- scope :filter_by_postcode, ->(postcode_full) { where("postcode_full ILIKE ?", "%#{postcode_full.gsub(/\s+/, '')}%") }
+ scope :filter_by_postcode, ->(postcode_full) { where("REPLACE(postcode_full, ' ', '') ILIKE ?", "%#{postcode_full.delete(' ')}%") }
scope :search_by, lambda { |param|
filter_by_id(param)
.or(filter_by_tenant_code(param))
@@ -118,6 +117,22 @@ class CaseLog < ApplicationRecord
end
end
+ def postcode_full=(postcode)
+ if postcode
+ super UKPostcode.parse(postcode).to_s
+ else
+ super nil
+ end
+ end
+
+ def ppostcode_full=(postcode)
+ if postcode
+ super UKPostcode.parse(postcode).to_s
+ else
+ super nil
+ end
+ end
+
def completed?
status == "completed"
end
diff --git a/app/models/location.rb b/app/models/location.rb
index b37687ae4..c6f727f5c 100644
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -9,7 +9,7 @@ class Location < ApplicationRecord
attr_accessor :add_another_location
- scope :search_by_postcode, ->(postcode) { where("postcode ILIKE ?", "%#{postcode.gsub(/\s+/, '')}%") }
+ scope :search_by_postcode, ->(postcode) { where("REPLACE(postcode, ' ', '') ILIKE ?", "%#{postcode.delete(' ')}%") }
scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }
scope :search_by, ->(param) { search_by_name(param).or(search_by_postcode(param)) }
@@ -42,6 +42,14 @@ class Location < ApplicationRecord
]
end
+ def postcode=(postcode)
+ if postcode
+ super UKPostcode.parse(postcode).to_s
+ else
+ super nil
+ end
+ end
+
private
PIO = PostcodeService.new
diff --git a/app/models/scheme.rb b/app/models/scheme.rb
index 82d259704..e899a31d4 100644
--- a/app/models/scheme.rb
+++ b/app/models/scheme.rb
@@ -8,8 +8,8 @@ class Scheme < ApplicationRecord
scope :filter_by_id, ->(id) { where(id: (id.start_with?("S") ? id[1..] : id)) }
scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") }
- scope :search_by_postcode, ->(postcode) { joins("LEFT JOIN locations ON locations.scheme_id = schemes.id").where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") }
- scope :search_by_location_name, ->(name) { joins("LEFT JOIN locations ON locations.scheme_id = schemes.id").where("locations.name ILIKE ?", "%#{name}%") }
+ scope :search_by_postcode, ->(postcode) { left_joins(:locations).where("REPLACE(locations.postcode, ' ', '') ILIKE ?", "%#{postcode.delete(' ')}%") }
+ scope :search_by_location_name, ->(name) { left_joins(:locations).where("locations.name ILIKE ?", "%#{name}%") }
scope :search_by, lambda { |param|
search_by_postcode(param)
.or(search_by_service_name(param))
diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb
index 814acfb43..96811487f 100644
--- a/app/services/imports/case_logs_import_service.rb
+++ b/app/services/imports/case_logs_import_service.rb
@@ -442,10 +442,10 @@ module Imports
def compose_postcode(xml_doc, outcode, incode)
outcode_value = string_or_nil(xml_doc, outcode)
incode_value = string_or_nil(xml_doc, incode)
- if outcode_value.nil? || incode_value.nil? || !"#{outcode_value}#{incode_value}".match(POSTCODE_REGEXP)
+ if outcode_value.nil? || incode_value.nil? || !"#{outcode_value} #{incode_value}".match(POSTCODE_REGEXP)
nil
else
- "#{outcode_value}#{incode_value}"
+ "#{outcode_value} #{incode_value}"
end
end
diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb
index 9b5c01a20..f8b5aafed 100644
--- a/spec/features/form/conditional_questions_spec.rb
+++ b/spec/features/form/conditional_questions_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe "Form Conditional Questions" do
it "is displayed correctly" do
case_log.update!(postcode_known: 1, postcode_full: "NW1 6RT")
visit("/logs/#{id}/property-postcode")
- expect(page).to have_field("case-log-postcode-full-field", with: "NW16RT")
+ expect(page).to have_field("case-log-postcode-full-field", with: "NW1 6RT")
end
end
end
diff --git a/spec/features/schemes_helpers.rb b/spec/features/schemes_helpers.rb
index 5db3917fa..d1a4db2dc 100644
--- a/spec/features/schemes_helpers.rb
+++ b/spec/features/schemes_helpers.rb
@@ -55,7 +55,7 @@ module SchemesHelpers
end
def fill_in_and_save_location
- fill_in "Postcode", with: "AA1 1AA"
+ fill_in "Postcode", with: "AA11AA"
fill_in "Location name (optional)", with: "Some name"
fill_in "Total number of units at this location", with: 5
fill_in "Day", with: 2
@@ -68,7 +68,7 @@ module SchemesHelpers
end
def fill_in_and_save_second_location
- fill_in "Postcode", with: "XX1 1XX"
+ fill_in "Postcode", with: "AA12AA"
fill_in "Location name (optional)", with: "Other name"
fill_in "Total number of units at this location", with: 2
choose "Self-contained house"
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index b76ecb891..9792dfc42 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -476,7 +476,7 @@ RSpec.describe "Schemes scheme Features" do
end
it "displays information about the first created location" do
- expect(page).to have_content "AA11AA"
+ expect(page).to have_content "AA1 1AA"
expect(page).to have_content "Some name"
expect(page).to have_content "5"
expect(page).to have_content "Self-contained house"
@@ -493,7 +493,7 @@ RSpec.describe "Schemes scheme Features" do
it "displays information about newly created location" do
click_link "Add a location"
fill_in_and_save_second_location
- expect(page).to have_content "XX11XX"
+ expect(page).to have_content "AA1 2AA"
expect(page).to have_content "Other name"
expect(page).to have_content "Self-contained house"
end
@@ -507,13 +507,13 @@ RSpec.describe "Schemes scheme Features" do
end
it "displays changed location" do
- click_link "XX11XX"
- fill_in "Postcode", with: "ZZ1 1ZZ"
+ click_link "AA1 2AA"
+ fill_in "Postcode", with: "AA1 3AA"
choose "location-mobility-type-wheelchair-user-standard-field"
click_button "Save and continue"
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
- expect(page).to have_content "ZZ11ZZ"
+ expect(page).to have_content "AA1 3AA"
end
end
diff --git a/spec/fixtures/exports/general_needs_log.csv b/spec/fixtures/exports/general_needs_log.csv
index e38480513..8a2dd1764 100644
--- a/spec/fixtures/exports/general_needs_log.csv
+++ b/spec/fixtures/exports/general_needs_log.csv
@@ -1,2 +1,2 @@
status,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,irproduct_other,reason,propcode,la,prevloc,hb,hbrentshortfall,mrcdate,incref,startdate,armedforces,unitletas,builtype,voiddate,renttype,needstype,lettype,totchild,totelder,totadult,nocharge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,ppcodenk,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,hhtype,new_old,vacdays,form,owningorgid,owningorgname,hcnum,maningorgid,maningorgname,manhcnum,createddate,uploaddate
-2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,0,1,0,1,2,1,5,1,SE26RT,6,7,3,2,1,68,1,1,2,2,1,NW15TY,1,1,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05 10:36:49 UTC,0,2022-02-02 10:36:49 UTC,1,2,1,2019-11-03 00:00:00 UTC,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08 16:52:15 UTC,2022-02-08 16:52:15 UTC
+2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,0,1,0,1,2,1,5,1,SE2 6RT,6,7,3,2,1,68,1,1,2,2,1,NW1 5TY,1,1,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05 10:36:49 UTC,0,2022-02-02 10:36:49 UTC,1,2,1,2019-11-03 00:00:00 UTC,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08 16:52:15 UTC,2022-02-08 16:52:15 UTC
diff --git a/spec/fixtures/exports/general_needs_log.xml b/spec/fixtures/exports/general_needs_log.xml
index b7d969c41..642b6ac6a 100644
--- a/spec/fixtures/exports/general_needs_log.xml
+++ b/spec/fixtures/exports/general_needs_log.xml
@@ -40,7 +40,7 @@
1
5
1
- SE26RT
+ SE2 6RT
6
7
3
@@ -52,7 +52,7 @@
2
2
1
- NW15TY
+ NW1 5TY
1
1
1
diff --git a/spec/fixtures/exports/supported_housing_logs.xml b/spec/fixtures/exports/supported_housing_logs.xml
index 849216392..b04a86b0c 100644
--- a/spec/fixtures/exports/supported_housing_logs.xml
+++ b/spec/fixtures/exports/supported_housing_logs.xml
@@ -40,7 +40,7 @@
1
1
- LE51QP
+ LE5 1QP
6
2
@@ -51,7 +51,7 @@
2
2
1
- SW1A2AA
+ SW1A 2AA
1
1
1
diff --git a/spec/fixtures/files/case_logs_download.csv b/spec/fixtures/files/case_logs_download.csv
index e55978624..9af96e3df 100644
--- a/spec/fixtures/files/case_logs_download.csv
+++ b/spec/fixtures/files/case_logs_download.csv
@@ -1,2 +1,2 @@
id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,owning_organisation_id,managing_organisation_id,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,created_by_id,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,unittype_sh
-{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,DLUHC,{owning_org_id},,Supported housing,,,false,0,0,0,,0,,,,,,,,,,,,,,false,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,Danny Rojas,,,,,,9,,,{scheme_id},SE11TE,6
+{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,DLUHC,{owning_org_id},,Supported housing,,,false,0,0,0,,0,,,,,,,,,,,,,,false,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,Danny Rojas,,,,,,9,,,{scheme_id},SE1 1TE,6
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 6b9c9658f..712e1eddf 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -1113,14 +1113,14 @@ RSpec.describe CaseLog do
def check_postcode_fields(postcode_field)
record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field} from case_logs where id=#{address_case_log.id}").to_a[0]
- expect(address_case_log[postcode_field]).to eq("M11AE")
- expect(record_from_db[postcode_field]).to eq("M11AE")
+ expect(address_case_log[postcode_field]).to eq("M1 1AE")
+ expect(record_from_db[postcode_field]).to eq("M1 1AE")
end
def check_previous_postcode_fields(postcode_field)
record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field} from case_logs where id=#{address_case_log.id}").to_a[0]
- expect(address_case_log[postcode_field]).to eq("M11AE")
- expect(record_from_db[postcode_field]).to eq("M11AE")
+ expect(address_case_log[postcode_field]).to eq("M1 1AE")
+ expect(record_from_db[postcode_field]).to eq("M1 1AE")
end
context "when saving addresses" do
@@ -1205,7 +1205,7 @@ RSpec.describe CaseLog do
address_case_log.update!({ postcode_known: 1, postcode_full: "M1 1AD" })
record_from_db = ActiveRecord::Base.connection.execute("select la, postcode_full from case_logs where id=#{address_case_log.id}").to_a[0]
- expect(record_from_db["postcode_full"]).to eq("M11AD")
+ expect(record_from_db["postcode_full"]).to eq("M1 1AD")
expect(address_case_log.la).to eq("E08000003")
expect(record_from_db["la"]).to eq("E08000003")
end
@@ -1295,7 +1295,7 @@ RSpec.describe CaseLog do
address_case_log.update!({ ppcodenk: 0, ppostcode_full: "M1 1AD" })
record_from_db = ActiveRecord::Base.connection.execute("select prevloc, ppostcode_full from case_logs where id=#{address_case_log.id}").to_a[0]
- expect(record_from_db["ppostcode_full"]).to eq("M11AD")
+ expect(record_from_db["ppostcode_full"]).to eq("M1 1AD")
expect(address_case_log.prevloc).to eq("E08000003")
expect(record_from_db["prevloc"]).to eq("E08000003")
end
@@ -1717,7 +1717,7 @@ RSpec.describe CaseLog do
it "correctly infers and saves postcode" do
record_from_db = ActiveRecord::Base.connection.execute("SELECT postcode_full from case_logs WHERE id=#{supported_housing_case_log.id}").to_a[0]
expect(record_from_db["postcode_full"]).to be_nil
- expect(supported_housing_case_log.postcode_full).to eq("M11AE")
+ expect(supported_housing_case_log.postcode_full).to eq("M1 1AE")
end
it "unittype_sh method returns the type_of_unit of the location" do
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index acf3bd618..dccc4674b 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -72,8 +72,8 @@ RSpec.describe Location, type: :model do
describe "scopes" do
before do
- FactoryBot.create(:location, name: "ABC", postcode: "NW18RR")
- FactoryBot.create(:location, name: "XYZ", postcode: "SE16HJ")
+ FactoryBot.create(:location, name: "ABC", postcode: "NW1 8RR")
+ FactoryBot.create(:location, name: "XYZ", postcode: "SE1 6HJ")
end
context "when searching by name" do
diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb
index 30007fc4d..4ca219c67 100644
--- a/spec/requests/case_logs_controller_spec.rb
+++ b/spec/requests/case_logs_controller_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe CaseLogsController, type: :request do
let(:age1) { 35 }
let(:offered) { 12 }
let(:period) { 2 }
- let(:postcode_full) { "SE116TY" }
+ let(:postcode_full) { "SE11 6TY" }
let(:in_progress) { "in_progress" }
let(:completed) { "completed" }
@@ -831,7 +831,7 @@ RSpec.describe CaseLogsController, type: :request do
it "updates the case log with the given fields and keeps original values where none are passed" do
case_log.reload
expect(case_log.tenancycode).to eq("New Value")
- expect(case_log.postcode_full).to eq("M11AE")
+ expect(case_log.postcode_full).to eq("M1 1AE")
end
context "with an invalid case log id" do
@@ -889,7 +889,7 @@ RSpec.describe CaseLogsController, type: :request do
it "updates the case log with the given fields and keeps original values where none are passed" do
case_log.reload
expect(case_log.tenancycode).to eq("New Value")
- expect(case_log.postcode_full).to eq("SW1A2AA")
+ expect(case_log.postcode_full).to eq("SW1A 2AA")
end
context "with an invalid case log id" do
diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb
index b981d7ffd..29387ffb3 100644
--- a/spec/requests/locations_controller_spec.rb
+++ b/spec/requests/locations_controller_spec.rb
@@ -108,7 +108,7 @@ RSpec.describe LocationsController, type: :request do
it "creates a new location for scheme with valid params" do
expect(Location.last.scheme.owning_organisation_id).to eq(user.organisation_id)
expect(Location.last.name).to eq("Test")
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow")
expect(Location.last.startdate).to eq(startdate)
@@ -119,7 +119,7 @@ RSpec.describe LocationsController, type: :request do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "zz1 1zz", mobility_type: "N" } } }
it "creates a new location for scheme with postcode " do
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
end
end
@@ -286,7 +286,7 @@ RSpec.describe LocationsController, type: :request do
it "creates a new location for scheme with valid params" do
expect(Location.last.name).to eq("Test")
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow")
end
@@ -295,7 +295,7 @@ RSpec.describe LocationsController, type: :request do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "zz1 1zz", mobility_type: "N" } } }
it "creates a new location for scheme with postcode " do
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
end
end
@@ -526,7 +526,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params" do
expect(Location.last.scheme.owning_organisation_id).to eq(user.organisation_id)
expect(Location.last.name).to eq("Test")
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow")
expect(Location.last.startdate).to eq(startdate)
@@ -550,7 +550,7 @@ RSpec.describe LocationsController, type: :request do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "zz1 1zz", page: "edit" } } }
it "updates existing location for scheme with postcode " do
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
end
end
@@ -657,7 +657,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params" do
expect(Location.last.name).to eq("Test")
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow")
end
@@ -680,7 +680,7 @@ RSpec.describe LocationsController, type: :request do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "zz1 1zz", page: "edit" } } }
it "updates a location for scheme with postcode " do
- expect(Location.last.postcode).to eq("ZZ11ZZ")
+ expect(Location.last.postcode).to eq("ZZ1 1ZZ")
end
end