If your organisation’s schemes were migrated from old CORE, they may have new names and codes. Search by postcode to find your scheme.
"
scheme_changes_link_text: "Read more about how schemes have changed"
view_schemes_link_text: "View your organisation’s schemes"
-
+
privacy_notice_tenant:
content: "Make sure the lead tenant has seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation."
privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice"
@@ -60,4 +60,11 @@ en:
housing benefit
child benefit
council tax support
- "
\ No newline at end of file
+ "
+
+ address_search:
+ title: "Can’t find the address you’re looking for?"
+ content: "
+
Some properties may not be available yet e.g. new builds; you might need to enter them manually instead
+
For UPRN (Unique Property Reference Number), please enter the full value exactly
+
"
diff --git a/config/locales/forms/2024/lettings/property_information.en.yml b/config/locales/forms/2024/lettings/property_information.en.yml
index 9e7326040..016c78958 100644
--- a/config/locales/forms/2024/lettings/property_information.en.yml
+++ b/config/locales/forms/2024/lettings/property_information.en.yml
@@ -50,6 +50,13 @@ en:
hint_text: ""
question_text: "Select the correct address"
+ address_search:
+ page_header: "What is the property's address?"
+ check_answer_label: "Address"
+ check_answer_prompt: "Enter address or UPRN"
+ hint_text: "For example, '1 Victoria Road' or '10010457355'"
+ question_text: "Enter address or UPRN"
+
address:
page_header: "What is the property's address?"
address_line1:
diff --git a/config/locales/forms/2024/sales/guidance.en.yml b/config/locales/forms/2024/sales/guidance.en.yml
index 801c43a5c..b57595c66 100644
--- a/config/locales/forms/2024/sales/guidance.en.yml
+++ b/config/locales/forms/2024/sales/guidance.en.yml
@@ -44,3 +44,10 @@ en:
privacy_notice_buyer:
content: "Make sure the buyer has seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation."
privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice"
+
+ address_search:
+ title: "Can’t find the address you’re looking for?"
+ content: "
+
Some properties may not be available yet e.g. new builds; you might need to enter them manually instead
+
For UPRN (Unique Property Reference Number), please enter the full value exactly
+
"
diff --git a/config/locales/forms/2024/sales/property_information.en.yml b/config/locales/forms/2024/sales/property_information.en.yml
index b40e40267..518654211 100644
--- a/config/locales/forms/2024/sales/property_information.en.yml
+++ b/config/locales/forms/2024/sales/property_information.en.yml
@@ -43,6 +43,13 @@ en:
hint_text: ""
question_text: "Select the correct address"
+ address_search:
+ page_header: "What is the property's address?"
+ check_answer_label: "Address"
+ check_answer_prompt: "Enter address or UPRN"
+ hint_text: "For example, '1 Victoria Road' or '10010457355'"
+ question_text: "Enter address or UPRN"
+
address:
page_header: "What is the property's address?"
address_line1:
diff --git a/config/locales/forms/2025/lettings/guidance.en.yml b/config/locales/forms/2025/lettings/guidance.en.yml
index 340eb11d5..cb51fbf9d 100644
--- a/config/locales/forms/2025/lettings/guidance.en.yml
+++ b/config/locales/forms/2025/lettings/guidance.en.yml
@@ -61,3 +61,10 @@ en:
Some properties may not be available yet e.g. new builds; you might need to enter them manually instead
+
For UPRN (Unique Property Reference Number), please enter the full value exactly
+
"
diff --git a/config/locales/forms/2025/lettings/property_information.en.yml b/config/locales/forms/2025/lettings/property_information.en.yml
index 22a0d12db..41cf2d3aa 100644
--- a/config/locales/forms/2025/lettings/property_information.en.yml
+++ b/config/locales/forms/2025/lettings/property_information.en.yml
@@ -10,45 +10,12 @@ en:
hint_text: ""
question_text: "Is this the first time the property has been let as social housing?"
- uprn:
- page_header: ""
- uprn_known:
- check_answer_label: "UPRN known"
- check_answer_prompt: "Enter UPRN if known"
- hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.
The UPRN may not be the same as the property reference assigned by your organisation.
If you don’t know the UPRN you can enter the address of the property instead on the next screen."
- question_text: "Do you know the property's UPRN?"
- uprn:
- check_answer_label: "UPRN"
- check_answer_prompt: ""
- hint_text: ""
- question_text: "What is the property's UPRN?"
-
- uprn_confirmed:
- page_header: "We found an address that might be this property"
- check_answer_label: "Is this the right address?"
- check_answer_prompt: "Tell us if this is the right address"
- hint_text: ""
- question_text: "Is this the property address?"
-
- address_matcher:
- page_header: "Find an address"
- address_line1_input:
- check_answer_label: "Find address"
- check_answer_prompt: "Try find address"
- hint_text: ""
- question_text: "Address line 1"
- postcode_full_input:
- check_answer_label: ""
- check_answer_prompt: ""
- hint_text: ""
- question_text: "Postcode"
-
- uprn_selection:
- page_header: "We found an address that might be this property"
- check_answer_label: "Select correct address"
- check_answer_prompt: "Select correct address"
- hint_text: ""
- question_text: "Select the correct address"
+ address_search:
+ page_header: "What is the property's address?"
+ check_answer_label: "Address"
+ check_answer_prompt: "Enter address or UPRN"
+ hint_text: "For example, '1 Victoria Road' or '10010457355'"
+ question_text: "Enter address or UPRN"
address:
page_header: "What is the property's address?"
diff --git a/config/locales/forms/2025/sales/guidance.en.yml b/config/locales/forms/2025/sales/guidance.en.yml
index 4ed6796b3..cfb9b0615 100644
--- a/config/locales/forms/2025/sales/guidance.en.yml
+++ b/config/locales/forms/2025/sales/guidance.en.yml
@@ -44,3 +44,10 @@ en:
privacy_notice_buyer:
content: "Make sure the buyer has seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation."
privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice"
+
+ address_search:
+ title: "Can’t find the address you’re looking for?"
+ content: "
+
Some properties may not be available yet e.g. new builds; you might need to enter them manually instead
+
For UPRN (Unique Property Reference Number), please enter the full value exactly
+
"
diff --git a/config/locales/forms/2025/sales/property_information.en.yml b/config/locales/forms/2025/sales/property_information.en.yml
index 332219a6b..e91089bc5 100644
--- a/config/locales/forms/2025/sales/property_information.en.yml
+++ b/config/locales/forms/2025/sales/property_information.en.yml
@@ -3,45 +3,12 @@ en:
2025:
sales:
property_information:
- uprn:
- page_header: ""
- uprn_known:
- check_answer_label: "UPRN known"
- check_answer_prompt: "Enter UPRN if known"
- hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.
The UPRN may not be the same as the property reference assigned by your organisation.
If you don’t know the UPRN you can enter the address of the property instead on the next screen."
- question_text: "Do you know the property's UPRN?"
- uprn:
- check_answer_label: "UPRN"
- check_answer_prompt: ""
- hint_text: ""
- question_text: "What is the property's UPRN?"
-
- uprn_confirmed:
- page_header: "We found an address that might be this property"
- check_answer_label: "Is this the right address?"
- check_answer_prompt: "Tell us if this is the right address"
- hint_text: ""
- question_text: "Is this the property address?"
-
- address_matcher:
- page_header: "Find an address"
- address_line1_input:
- check_answer_label: "Find address"
- check_answer_prompt: "Try find address"
- hint_text: ""
- question_text: "Address line 1"
- postcode_full_input:
- check_answer_label: ""
- check_answer_prompt: ""
- hint_text: ""
- question_text: "Postcode"
-
- uprn_selection:
- page_header: "We found an address that might be this property"
- check_answer_label: "Select correct address"
- check_answer_prompt: "Select correct address"
- hint_text: ""
- question_text: "Select the correct address"
+ address_search:
+ page_header: "What is the property's address?"
+ check_answer_label: "Address"
+ check_answer_prompt: "Enter address or UPRN"
+ hint_text: "For example, '1 Victoria Road' or '10010457355'"
+ question_text: "Enter address or UPRN"
address:
page_header: "What is the property's address?"
diff --git a/config/locales/validations/sales/property_information.en.yml b/config/locales/validations/sales/property_information.en.yml
index 9014f1d78..f421177af 100644
--- a/config/locales/validations/sales/property_information.en.yml
+++ b/config/locales/validations/sales/property_information.en.yml
@@ -7,7 +7,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "Enter a postcode in the correct format, for example AA1 1AA."
- not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"
+ not_in_england: "It looks like you have entered a postcode outside of England. Only create logs for sales in England."
ppostcode_full:
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
@@ -21,7 +21,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "UPRN must be 12 digits or less."
- not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
beds:
bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit."
proptype:
@@ -29,11 +29,11 @@ en:
uprn_known:
invalid: "You must answer UPRN known?"
la:
- not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
uprn_confirmation:
- not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
uprn_selection:
- not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
saledate:
- postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
- address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ postcode_not_in_england: "It looks like you have entered a postcode outside of England. Only create logs for sales in England."
+ address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
diff --git a/config/routes.rb b/config/routes.rb
index 471c89578..304d54ef0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -39,6 +39,10 @@ Rails.application.routes.draw do
get "/data-sharing-agreement", to: "content#data_sharing_agreement"
get "/service-moved", to: "maintenance#service_moved"
get "/service-unavailable", to: "maintenance#service_unavailable"
+ get "/address-search", to: "address_search#index"
+ get "/address-search/current", to: "address_search#current"
+ get "/address-search/manual-input/:log_type/:log_id", to: "address_search#manual_input", as: "address_manual_input"
+ get "/address-search/search-input/:log_type/:log_id", to: "address_search#search_input", as: "address_search_input"
get "collection-resources", to: "collection_resources#index"
get "/collection-resources/:log_type/:year/:resource_type/download", to: "collection_resources#download_mandatory_collection_resource", as: :download_mandatory_collection_resource
diff --git a/db/migrate/20250219122817_add_manual_address_entry_selected_to_logs.rb b/db/migrate/20250219122817_add_manual_address_entry_selected_to_logs.rb
new file mode 100644
index 000000000..a0d0f7529
--- /dev/null
+++ b/db/migrate/20250219122817_add_manual_address_entry_selected_to_logs.rb
@@ -0,0 +1,6 @@
+class AddManualAddressEntrySelectedToLogs < ActiveRecord::Migration[7.2]
+ def change
+ add_column :sales_logs, :manual_address_entry_selected, :boolean, default: false
+ add_column :lettings_logs, :manual_address_entry_selected, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 20a836eed..82d67b432 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -771,6 +771,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_25_180643) do
t.decimal "mrentprestaircasing", precision: 10, scale: 2
t.datetime "lasttransaction"
t.datetime "initialpurchase"
+ t.boolean "manual_address_entry_selected", default: false
t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb
index 5d13cacfa..ad81bca5d 100644
--- a/spec/factories/lettings_log.rb
+++ b/spec/factories/lettings_log.rb
@@ -6,6 +6,7 @@ FactoryBot.define do
managing_organisation { assigned_to.organisation }
created_at { Time.zone.today }
updated_at { Time.zone.today }
+ manual_address_entry_selected { true }
before(:create) do |log, _evaluator|
if log.period && !log.managing_organisation.organisation_rent_periods.exists?(rent_period: log.period)
@@ -167,13 +168,11 @@ FactoryBot.define do
town_or_city { Faker::Address.city }
ppcodenk { 1 }
tshortfall_known { 1 }
- after(:build) do |log, _evaluator|
+ after(:build) do |log, evaluator|
if log.startdate >= Time.zone.local(2024, 4, 1)
- log.address_line1_input = log.address_line1
- log.postcode_full_input = log.postcode_full
log.nationality_all_group = 826
- log.uprn = "10033558653"
- log.uprn_selection = 1
+ log.uprn = evaluator.uprn || "10033558653"
+ log.uprn_selection = evaluator.uprn_selection || "10033558653"
end
end
end
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 820c99fdc..64137704c 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -8,6 +8,8 @@ FactoryBot.define do
managing_organisation { assigned_to.organisation }
created_at { Time.zone.now }
updated_at { Time.zone.now }
+ manual_address_entry_selected { true }
+
trait :in_progress do
purchid { "PC123" }
ownershipsch { 2 }
@@ -166,14 +168,12 @@ FactoryBot.define do
nationalbuy2 { 13 }
buy2living { 3 }
proplen_asked { 1 }
- after(:build) do |log, _evaluator|
+ after(:build) do |log, evaluator|
if log.saledate >= Time.zone.local(2024, 4, 1)
- log.address_line1_input = log.address_line1
- log.postcode_full_input = log.postcode_full
log.nationality_all_group = 826
log.nationality_all_buyer2_group = 826
- log.uprn = "10033558653"
- log.uprn_selection = 1
+ log.uprn = evaluator.uprn || "10033558653"
+ log.uprn_selection = evaluator.uprn_selection || "10033558653"
end
if log.saledate >= Time.zone.local(2025, 4, 1)
log.relat2 = "X" if log.relat2 == "C"
diff --git a/spec/features/form/address_search_spec.rb b/spec/features/form/address_search_spec.rb
new file mode 100644
index 000000000..cd1738195
--- /dev/null
+++ b/spec/features/form/address_search_spec.rb
@@ -0,0 +1,45 @@
+require "rails_helper"
+require_relative "helpers"
+
+RSpec.describe "Address Search" do
+ include Helpers
+ let(:user) { FactoryBot.create(:user) }
+ let(:sales_log) do
+ FactoryBot.create(
+ :sales_log,
+ :shared_ownership_setup_complete,
+ assigned_to: user,
+ manual_address_entry_selected: false,
+ )
+ end
+
+ before do
+ sign_in user
+ end
+
+ context "when using address search feature" do
+ before do
+ visit("/sales-logs/#{sales_log.id}/address-search")
+ end
+
+ it "allows searching by a UPRN", js: true do
+ find("#sales-log-uprn-field").click.native.send_keys("1", "0", "0", "3", "3", "5", "4", "4", "6", "1", "4", :down)
+ expect(find("#sales-log-uprn-field").value).to eq("10033544614")
+ end
+
+ it "allows searching by address", js: true do
+ find("#sales-log-uprn-field").click.native.send_keys("S", "W", "1", "5", :down, :enter)
+ expect(find("#sales-log-uprn-field").value).to eq("SW15")
+ end
+
+ it "displays the placeholder text", js: true do
+ expect(find("#sales-log-uprn-field")["placeholder"]).to eq("Start typing to search")
+ end
+
+ it "displays correct bottom guidance text" do
+ find("span.govuk-details__summary-text", text: "Can’t find the address you’re looking for?").click
+ expect(page).to have_content("Some properties may not be available yet e.g. new builds; you might need to enter them manually instead")
+ expect(page).to have_content("For UPRN (Unique Property Reference Number), please enter the full value exactly")
+ end
+ end
+end
diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb
index 6484fe94c..695115a78 100644
--- a/spec/features/form/form_navigation_spec.rb
+++ b/spec/features/form/form_navigation_spec.rb
@@ -186,64 +186,4 @@ RSpec.describe "Form Navigation" do
expect(page).to have_current_path("/lettings-logs/#{id}/duplicate-logs?original_log_id=#{id}")
end
end
-
- describe "searching for an address" do
- let(:now) { Time.zone.local(2024, 5, 1) }
-
- context "with a lettings log" do
- let(:lettings_log) { create(:lettings_log, :setup_completed, startdate: Time.zone.local(2024, 5, 5), assigned_to: user) }
-
- before do
- stub_request(:get, /api\.os\.uk/)
- .to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.9, BUILDING_NAME: "result address line 1", POST_TOWN: "result town or city", POSTCODE: "AA1 1AA", UPRN: "12345" } }] }.to_json, headers: {})
- end
-
- it "allows searching for an address" do
- visit("lettings-logs/#{id}/address-matcher")
- fill_in("lettings-log-address-line1-input-field", with: "address")
- fill_in("lettings-log-postcode-full-input-field", with: "A1 1AA")
- click_button(text: "Search")
- expect(page).to have_current_path("/lettings-logs/#{id}/uprn-selection")
- end
-
- it "allows searching for an address from check your answers page" do
- visit("lettings-logs/#{id}/address-matcher?referrer=check_answers")
- fill_in("lettings-log-address-line1-input-field", with: "address")
- fill_in("lettings-log-postcode-full-input-field", with: "A1 1AA")
- click_button(text: "Search")
- expect(page).to have_current_path("/lettings-logs/#{id}/uprn-selection?referrer=check_answers&unanswered_pages=property_local_authority")
- choose("lettings-log-uprn-selection-12345-field", allow_label_click: true)
- click_button(text: "Save changes")
- expect(page).to have_current_path("/lettings-logs/#{id}/property-information/check-answers")
- end
- end
-
- context "with a sales log" do
- let(:sales_log) { create(:sales_log, :outright_sale_setup_complete, saledate: Time.zone.local(2024, 5, 5), assigned_to: user) }
-
- before do
- stub_request(:get, /api\.os\.uk/)
- .to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.9, BUILDING_NAME: "result address line 1", POST_TOWN: "result town or city", POSTCODE: "AA1 1AA", UPRN: "12345" } }] }.to_json, headers: {})
- end
-
- it "allows searching for an address" do
- visit("sales-logs/#{sales_log.id}/address-matcher")
- fill_in("sales-log-address-line1-input-field", with: "address")
- fill_in("sales-log-postcode-full-input-field", with: "A1 1AA")
- click_button(text: "Search")
- expect(page).to have_current_path("/sales-logs/#{sales_log.id}/uprn-selection")
- end
-
- it "allows searching for an address from check your answers page" do
- visit("sales-logs/#{sales_log.id}/address-matcher?referrer=check_answers")
- fill_in("sales-log-address-line1-input-field", with: "address")
- fill_in("sales-log-postcode-full-input-field", with: "A1 1AA")
- click_button(text: "Search")
- expect(page).to have_current_path("/sales-logs/#{sales_log.id}/uprn-selection?referrer=check_answers&unanswered_pages=property_local_authority")
- choose("sales-log-uprn-selection-12345-field", allow_label_click: true)
- click_button(text: "Save changes")
- expect(page).to have_current_path("/sales-logs/#{sales_log.id}/property-information/check-answers")
- end
- end
- end
end
diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb
index a400ef2d0..15d24e5ed 100644
--- a/spec/features/lettings_log_spec.rb
+++ b/spec/features/lettings_log_spec.rb
@@ -729,380 +729,5 @@ RSpec.describe "Lettings Log Features" do
expect(duplicate_log.duplicate_set_id).to be_nil
end
end
-
- context "when filling out address fields" do
- let(:lettings_log) { create(:lettings_log, :setup_completed, assigned_to: user) }
-
- before do
- body = {
- results: [
- {
- DPA: {
- "POSTCODE": "AA1 1AA",
- "POST_TOWN": "Bristol",
- "ORGANISATION_NAME": "Some place",
- },
- },
- ],
- }.to_json
-
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key=OS_DATA_KEY&uprn=111")
- .to_return(status: 200, body:, headers: {})
-
- body = { results: [{ DPA: { UPRN: "111" } }] }.to_json
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?query=Address+line+1%2C+AA1+1AA&key=OS_DATA_KEY&maxresults=10&minmatch=0.4")
- .to_return(status: 200, body:, headers: {})
-
- WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA11AA")
- .to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"AA1 1AA\",\"admin_district\":\"Westminster\",\"codes\":{\"admin_district\":\"E09000033\"}}}", headers: {})
-
- WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA12AA")
- .to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"AA1 2AA\",\"admin_district\":\"Wigan\",\"codes\":{\"admin_district\":\"E08000010\"}}}", headers: {})
-
- body = { results: [] }.to_json
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?query=Address+line+1%2C+AA1+1AB&key=OS_DATA_KEY&maxresults=10&minmatch=0.4")
- .to_return(status: 200, body:, headers: {})
-
- visit("/lettings-logs/#{lettings_log.id}/uprn")
- end
-
- context "and uprn is known and answered" do
- before do
- choose "Yes"
- fill_in("lettings_log[uprn]", with: "111")
- click_button("Save and continue")
- end
-
- context "and uprn is confirmed" do
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(1) # yes
- expect(lettings_log.uprn).to eq("111")
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Some Place")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq("Bristol")
- expect(lettings_log.address_line1_input).to eq(nil)
- expect(lettings_log.postcode_full_input).to eq(nil)
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
-
- choose "Yes"
- click_button("Save and continue")
-
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(1) # yes
- expect(lettings_log.uprn).to eq("111")
- expect(lettings_log.uprn_confirmed).to eq(1) # yes
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Some Place")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq("Bristol")
- expect(lettings_log.address_line1_input).to eq(nil)
- expect(lettings_log.postcode_full_input).to eq(nil)
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
- end
-
- context "and changes to uprn not known" do
- it "sets correct address fields" do
- visit("/lettings-logs/#{lettings_log.id}/uprn")
-
- choose "No"
- click_button("Save and continue")
-
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq(nil)
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq(nil)
- expect(lettings_log.postcode_full_input).to eq(nil)
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq(nil)
- end
- end
- end
-
- context "and uprn is not confirmed" do
- before do
- choose "No, I want to search for the address instead"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
-
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq(nil)
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq(nil)
- expect(lettings_log.postcode_full_input).to eq(nil)
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq(nil)
- end
- end
- end
-
- context "and uprn is not known" do
- before do
- choose "No"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq(nil)
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq(nil)
- expect(lettings_log.postcode_full_input).to eq(nil)
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq(nil)
- end
-
- context "and the address is not found" do
- it "sets correct address fields" do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AB")
- click_button("Search")
-
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq(nil)
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AB")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq(nil)
-
- click_button("Confirm and continue")
-
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq(nil)
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AB")
- expect(lettings_log.address_search_value_check).to eq(0)
- expect(lettings_log.la).to eq(nil)
- end
- end
-
- context "and address is found, re-searched and not found" do
- before do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- visit("/lettings-logs/#{lettings_log.id}/address-matcher")
-
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AB")
- click_button("Search")
- end
-
- it "routes to the correct page" do
- expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/no-address-found")
- end
- end
-
- context "and the user selects 'address_not_listed'" do
- before do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq("uprn_not_listed")
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Address line 1")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AA")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
- end
-
- context "and the user enters a new address manually" do
- context "without changing a valid postcode" do
- before do
- fill_in("lettings_log[town_or_city]", with: "Town")
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq("uprn_not_listed")
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Address line 1")
- expect(lettings_log.address_line2).to eq("")
- expect(lettings_log.town_or_city).to eq("Town")
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AA")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
- end
- end
-
- context "with changing the postcode" do
- before do
- fill_in("lettings_log[town_or_city]", with: "Town")
- fill_in("lettings_log[postcode_full]", with: "AA12AA")
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq("uprn_not_listed")
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 2AA")
- expect(lettings_log.address_line1).to eq("Address line 1")
- expect(lettings_log.address_line2).to eq("")
- expect(lettings_log.town_or_city).to eq("Town")
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AA")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E08000010")
- end
- end
- end
- end
-
- context "and the user selects 'address_not_listed' when partial postcode is entered" do
- before do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(0) # no
- expect(lettings_log.uprn).to eq(nil)
- expect(lettings_log.uprn_confirmed).to eq(nil)
- expect(lettings_log.uprn_selection).to eq("uprn_not_listed")
- expect(lettings_log.postcode_known).to eq(nil)
- expect(lettings_log.postcode_full).to eq(nil)
- expect(lettings_log.address_line1).to eq("Address line 1")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq(nil)
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq(nil)
- end
- end
-
- context "and the user selects 'address_not_listed' and then changes their mind and selects an address" do
- before do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
-
- visit("/lettings-logs/#{lettings_log.id}/uprn-selection")
- choose("lettings-log-uprn-selection-111-field", allow_label_click: true)
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(1)
- expect(lettings_log.uprn).to eq("111")
- expect(lettings_log.uprn_confirmed).to eq(1)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Some Place")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq("Bristol")
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AA")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
- end
- end
-
- context "and possible addresses found and selected" do
- before do
- fill_in("lettings_log[address_line1_input]", with: "Address line 1")
- fill_in("lettings_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose("lettings-log-uprn-selection-111-field", allow_label_click: true)
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- lettings_log.reload
- expect(lettings_log.uprn_known).to eq(1)
- expect(lettings_log.uprn).to eq("111")
- expect(lettings_log.uprn_confirmed).to eq(1)
- expect(lettings_log.uprn_selection).to eq(nil)
- expect(lettings_log.postcode_known).to eq(1)
- expect(lettings_log.postcode_full).to eq("AA1 1AA")
- expect(lettings_log.address_line1).to eq("Some Place")
- expect(lettings_log.address_line2).to eq(nil)
- expect(lettings_log.town_or_city).to eq("Bristol")
- expect(lettings_log.address_line1_input).to eq("Address line 1")
- expect(lettings_log.postcode_full_input).to eq("AA1 1AA")
- expect(lettings_log.address_search_value_check).to eq(nil)
- expect(lettings_log.la).to eq("E09000033")
- end
- end
- end
- end
end
end
diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb
index 3030d6d6a..3fa89a504 100644
--- a/spec/features/sales_log_spec.rb
+++ b/spec/features/sales_log_spec.rb
@@ -334,381 +334,6 @@ RSpec.describe "Sales Log Features" do
expect(page).to have_current_path("/sales-logs/bulk-uploads")
end
end
-
- context "when filling out address fields" do
- let(:sales_log) { create(:sales_log, :shared_ownership_setup_complete, assigned_to: user) }
-
- before do
- body = {
- results: [
- {
- DPA: {
- "POSTCODE": "AA1 1AA",
- "POST_TOWN": "Bristol",
- "ORGANISATION_NAME": "Some place",
- },
- },
- ],
- }.to_json
-
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key=OS_DATA_KEY&uprn=111")
- .to_return(status: 200, body:, headers: {})
-
- body = { results: [{ DPA: { UPRN: "111" } }] }.to_json
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?query=Address+line+1%2C+AA1+1AA&key=OS_DATA_KEY&maxresults=10&minmatch=0.4")
- .to_return(status: 200, body:, headers: {})
-
- WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA11AA")
- .to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"AA1 1AA\",\"admin_district\":\"Westminster\",\"codes\":{\"admin_district\":\"E09000033\"}}}", headers: {})
-
- WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA12AA")
- .to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"AA1 2AA\",\"admin_district\":\"Wigan\",\"codes\":{\"admin_district\":\"E08000010\"}}}", headers: {})
-
- body = { results: [] }.to_json
- WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?query=Address+line+1%2C+AA1+1AB&key=OS_DATA_KEY&maxresults=10&minmatch=0.4")
- .to_return(status: 200, body:, headers: {})
-
- visit("/sales-logs/#{sales_log.id}/uprn")
- end
-
- context "and uprn is known and answered" do
- before do
- choose "Yes"
- fill_in("sales_log[uprn]", with: "111")
- click_button("Save and continue")
- end
-
- context "and uprn is confirmed" do
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(1) # yes
- expect(sales_log.uprn).to eq("111")
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Some Place")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq("Bristol")
- expect(sales_log.address_line1_input).to eq(nil)
- expect(sales_log.postcode_full_input).to eq(nil)
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
-
- choose "Yes"
- click_button("Save and continue")
-
- sales_log.reload
- expect(sales_log.uprn_known).to eq(1) # yes
- expect(sales_log.uprn).to eq("111")
- expect(sales_log.uprn_confirmed).to eq(1) # yes
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Some Place")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq("Bristol")
- expect(sales_log.address_line1_input).to eq(nil)
- expect(sales_log.postcode_full_input).to eq(nil)
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
- end
-
- context "and changes to uprn not known" do
- it "sets correct address fields" do
- visit("/sales-logs/#{sales_log.id}/uprn")
-
- choose "No"
- click_button("Save and continue")
-
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq(nil)
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq(nil)
- expect(sales_log.postcode_full_input).to eq(nil)
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq(nil)
- end
- end
- end
-
- context "and uprn is not confirmed" do
- before do
- choose "No, I want to search for the address instead"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
-
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq(nil)
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq(nil)
- expect(sales_log.postcode_full_input).to eq(nil)
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq(nil)
- end
- end
- end
-
- context "and uprn is not known" do
- before do
- choose "No"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq(nil)
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq(nil)
- expect(sales_log.postcode_full_input).to eq(nil)
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq(nil)
- end
-
- context "and the address is not found" do
- it "sets correct address fields" do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AB")
- click_button("Search")
-
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq(nil)
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AB")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq(nil)
-
- click_button("Confirm and continue")
-
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq(nil)
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AB")
- expect(sales_log.address_search_value_check).to eq(0)
- expect(sales_log.la).to eq(nil)
- end
- end
-
- context "and address is found, re-searched and not found" do
- before do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- visit("/sales-logs/#{sales_log.id}/address-matcher")
-
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AB")
- click_button("Search")
- end
-
- it "routes to the correct page" do
- expect(page).to have_current_path("/sales-logs/#{sales_log.id}/no-address-found")
- end
- end
-
- context "and the user selects 'address_not_listed'" do
- before do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq("uprn_not_listed")
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Address line 1")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
- end
-
- context "and the user enters a new address manually" do
- context "without changing a valid postcode" do
- before do
- fill_in("sales_log[town_or_city]", with: "Town")
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq("uprn_not_listed")
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Address line 1")
- expect(sales_log.address_line2).to eq("")
- expect(sales_log.town_or_city).to eq("Town")
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
- end
- end
-
- context "with changing the postcode" do
- before do
- fill_in("sales_log[town_or_city]", with: "Town")
- fill_in("sales_log[postcode_full]", with: "AA12AA")
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq("uprn_not_listed")
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 2AA")
- expect(sales_log.address_line1).to eq("Address line 1")
- expect(sales_log.address_line2).to eq("")
- expect(sales_log.town_or_city).to eq("Town")
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E08000010")
- end
- end
- end
- end
-
- context "and the user selects 'address_not_listed' when partial postcode is given" do
- before do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "1AA")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(0) # no
- expect(sales_log.uprn).to eq(nil)
- expect(sales_log.uprn_confirmed).to eq(nil)
- expect(sales_log.uprn_selection).to eq("uprn_not_listed")
- expect(sales_log.pcodenk).to eq(nil)
- expect(sales_log.postcode_full).to eq(nil)
- expect(sales_log.address_line1).to eq("Address line 1")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq(nil)
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq(nil)
- end
- end
-
- context "and the user selects 'address_not_listed' and then changes their mind and selects an address" do
- before do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose "The address is not listed, I want to enter the address manually"
- click_button("Save and continue")
-
- visit("/sales-logs/#{sales_log.id}/uprn-selection")
- choose("sales-log-uprn-selection-111-field", allow_label_click: true)
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(1)
- expect(sales_log.uprn).to eq("111")
- expect(sales_log.uprn_confirmed).to eq(1)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Some Place")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq("Bristol")
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
- end
- end
-
- context "and possible addresses found and selected" do
- before do
- fill_in("sales_log[address_line1_input]", with: "Address line 1")
- fill_in("sales_log[postcode_full_input]", with: "AA1 1AA")
- click_button("Search")
- choose("sales-log-uprn-selection-111-field", allow_label_click: true)
- click_button("Save and continue")
- end
-
- it "sets correct address fields" do
- sales_log.reload
- expect(sales_log.uprn_known).to eq(1)
- expect(sales_log.uprn).to eq("111")
- expect(sales_log.uprn_confirmed).to eq(1)
- expect(sales_log.uprn_selection).to eq(nil)
- expect(sales_log.pcodenk).to eq(0)
- expect(sales_log.postcode_full).to eq("AA1 1AA")
- expect(sales_log.address_line1).to eq("Some Place")
- expect(sales_log.address_line2).to eq(nil)
- expect(sales_log.town_or_city).to eq("Bristol")
- expect(sales_log.address_line1_input).to eq("Address line 1")
- expect(sales_log.postcode_full_input).to eq("AA1 1AA")
- expect(sales_log.address_search_value_check).to eq(nil)
- expect(sales_log.la).to eq("E09000033")
- end
- end
- end
- end
end
context "when a log becomes a duplicate" do
diff --git a/spec/fixtures/files/sales_logs_csv_export_codes_24.csv b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv
index e0ebccb38..f874e4e75 100644
--- a/spec/fixtures/files/sales_logs_csv_export_codes_24.csv
+++ b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv
@@ -1,3 +1,3 @@
Log ID,Status of log,ID of a set of duplicate logs,Time and date the log was created,Time and date the log was last updated,Year collection period opened,Was the log submitted in-service or via bulk upload?,ID of a set of bulk uploaded logs,Is the user in the created_by column the data protection officer?,Day of sale completion date,Month of sale completion date,Year of sale completion date,Which organisation owned this property before the sale?,Which organisation reported the sale?,User that created the log,User the log is assigned to,What is the purchaser code?,Was this purchase made through an ownership scheme?,What is the type of shared ownership/discounted ownership/outright sale?,"If type = 'Other', what is the type of outright sale?",Is the buyer a company?,Will the buyer(s) live in the property?,Is this a joint purchase?,Are there more than 2 joint buyers of this property?,Did you interview the buyer to answer these questions?,Has the buyer seen the MHCLG privacy notice?,What is the UPRN of the property?,Address line 1,Address line 2,Town/City,County,Postcode,The internal value to indicate if the LA was inferred from the postcode,LA name,LA code,UPRN of the address selected,Was the 'No address found' page seen?,Address line 1 input from address matching feature,Postcode input from address matching feature,Address line 1 entered in bulk upload file,Address line 2 entered in bulk upload file,Town or city entered in bulk upload file,County entered in bulk upload file,Postcode entered in bulk upload file,Local authority entered in bulk upload file,How many bedrooms does the property have?,What type of unit is the property?,Which type of building is the property?,Is the property built or adapted to wheelchair-user standards?,What is buyer 1's age?,Which of these best describes buyer 1's gender identity?,What is buyer 1's ethnic group?,Which of the following best describes buyer 1's ethnic background?,What is buyer 1's nationality?,Which of these best describes buyer 1's working situation?,Will buyer 1 live in the property?,What is buyer 2 or person 2's relationship to buyer 1?,What is buyer 2 or person 2's age?,Which of these best describes buyer 2 or person 2's gender identity?,What is buyer 2's ethnic group?,Which of the following best describes buyer 2's ethnic background?,What is buyer 2's nationality?,What is buyer 2 or person 2's working situation?,Will buyer 2 live in the property?,"Besides the buyer(s), how many other people live or will live in the property?",What is person 3's relationship to buyer 1?,What is person 3's age?,What is person 3's gender identity?,What is person 3's working situation?,What is person 4's relationship to buyer 1?,What is person 4's age?,What is person 4's gender identity?,What is person 4's working situation?,What is person 5's relationship to buyer 1?,What is person 5's age?,What is person 5's gender identity?,What is person 5's working situation?,What is person 6's relationship to buyer 1?,What is person 6's age?,What is person 6's gender identity?,What is person 6's working situation?,What was buyer 1's previous tenure?,Do you know the postcode of buyer 1's last settled accommodation?,Part 1 of postcode of buyer 1's last settled accommodation,Part 2 of postcode of buyer 1's last settled accommodation,Do you know the local authority of buyer 1's last settled accommodation?,The local authority code of buyer 1's last settled accommodation,The local authority name of buyer 1's last settled accommodation,Was the buyer registered with their PRP (HA)?,Was the buyer registered with another PRP (HA)?,Was the buyer registered with the local authority?,Was the buyer registered with a Help to Buy agent?,"Populated if pregyrha, pregother, pregla and pregghb are blank","At the time of purchase, was buyer 2 living at the same address as buyer 1?",What was buyer 2's previous tenure?,Have any of the buyers ever served as a regular in the UK armed forces?,Is the buyer still serving in the UK armed forces?,Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,Is buyer 1's annual income known?,What is buyer 1's annual income?,Was buyer 1's income used for a mortgage application?,Is buyer 1's annual income known?,What is buyer 2's annual income?,Was buyer 2's income used for a mortgage application?,Were the buyers receiving any of these housing-related benefits immediately before buying this property?,Is the the total amount the buyers had in savings known?,What is the total amount the buyers had in savings before they paid any deposit for the property?,Have any of the buyers previously owned a property?,Was the previous property under shared ownership?,How long did the buyer(s) live in the property before purchasing it?,Is this a staircasing transaction?,What percentage of the property has been bought in this staircasing transaction?,What percentage of the property do the buyers now own in total?,Was this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?,Is this a resale?,Day of the exchange of contracts,Month of the exchange of contracts,Year of the exchange of contracts,Day of the practical completion or handover date,Month of the practical completion or handover date,Year of the practical completion or handover date,Was the household rehoused under a local authority nominations agreement?,"Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?",How many bedrooms did the buyer's previous property have?,What was the previous property type?,What was the rent type of buyer's previous tenure?,What is the full purchase price?,Populated if a soft validation is confirmed.,What was the initial percentage equity stake purchased?,Was a mortgage used to buy this property?,What is the mortgage amount?,What is the name of the mortgage lender?,"If mortgagelender = 'Other', what is the name of the mortgage lender?",What is the length of the mortgage in years?,Does this include any extra borrowing?,How much was the cash deposit paid on the property?,How much cash discount was given through Social Homebuy?,What is the basic monthly rent?,Does the property have any monthly leasehold charges?,What are the total monthly leasehold charges for the property?,Populated if a soft validation is confirmed.,What was the percentage discount?,"What was the amount of any loan, grant, discount or subsidy given?"
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,DAY,MONTH,YEAR,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
-,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,1,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,billyboy@eyeklaud.com,,2,8,,,,1,1,2,1,1,"1, Test Street",,Test Town,,AA1 1AA,true,Westminster,E09000033,,,Address line 1,SW1A 1AA,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,1,1,1,30,X,17,17,826,1,1,P,35,X,17,,826,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,0,SW1A,1AA,1,E09000033,Westminster,1,1,1,1,,3,,1,4,5,1,1,0,13400,1,0,13400,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0
+,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,1,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,billyboy@eyeklaud.com,,2,8,,,,1,1,2,1,1,"1, Test Street",,Test Town,,AA1 1AA,true,Westminster,E09000033,1,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,1,1,1,30,X,17,17,826,1,1,P,35,X,17,,826,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,0,SW1A,1AA,1,E09000033,Westminster,1,1,1,1,,3,,1,4,5,1,1,0,13400,1,0,13400,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0
diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv
index ffda37642..a66a16201 100644
--- a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv
+++ b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv
@@ -1,3 +1,3 @@
Log ID,Status of log,ID of a set of duplicate logs,Time and date the log was created,Time and date the log was last updated,Year collection period opened,Was the log submitted in-service or via bulk upload?,ID of a set of bulk uploaded logs,Is the user in the created_by column the data protection officer?,Day of sale completion date,Month of sale completion date,Year of sale completion date,Which organisation owned this property before the sale?,Which organisation reported the sale?,User that created the log,User the log is assigned to,What is the purchaser code?,Was this purchase made through an ownership scheme?,What is the type of shared ownership/discounted ownership/outright sale?,"If type = 'Other', what is the type of outright sale?",Is the buyer a company?,Will the buyer(s) live in the property?,Is this a joint purchase?,Are there more than 2 joint buyers of this property?,Did you interview the buyer to answer these questions?,Has the buyer seen the MHCLG privacy notice?,"What is the UPRN of the property?",Address line 1,Address line 2,Town/City,County,Postcode,The internal value to indicate if the LA was inferred from the postcode,LA name,LA code,UPRN of the address selected,Was the 'No address found' page seen?,Address line 1 input from address matching feature,Postcode input from address matching feature,Address line 1 entered in bulk upload file,Address line 2 entered in bulk upload file,Town or city entered in bulk upload file,County entered in bulk upload file,Postcode entered in bulk upload file,Local authority entered in bulk upload file,How many bedrooms does the property have?,What type of unit is the property?,Which type of building is the property?,Is the property built or adapted to wheelchair-user standards?,What is buyer 1's age?,Which of these best describes buyer 1's gender identity?,What is buyer 1's ethnic group?,Which of the following best describes buyer 1's ethnic background?,What is buyer 1's nationality?,Which of these best describes buyer 1's working situation?,Will buyer 1 live in the property?,What is buyer 2 or person 2's relationship to buyer 1?,What is buyer 2 or person 2's age?,Which of these best describes buyer 2 or person 2's gender identity?,What is buyer 2's ethnic group?,Which of the following best describes buyer 2's ethnic background?,What is buyer 2's nationality?,What is buyer 2 or person 2's working situation?,Will buyer 2 live in the property?,"Besides the buyer(s), how many other people live or will live in the property?",What is person 3's relationship to buyer 1?,What is person 3's age?,What is person 3's gender identity?,What is person 3's working situation?,What is person 4's relationship to buyer 1?,What is person 4's age?,What is person 4's gender identity?,What is person 4's working situation?,What is person 5's relationship to buyer 1?,What is person 5's age?,What is person 5's gender identity?,What is person 5's working situation?,What is person 6's relationship to buyer 1?,What is person 6's age?,What is person 6's gender identity?,What is person 6's working situation?,What was buyer 1's previous tenure?,Do you know the postcode of buyer 1's last settled accommodation?,Part 1 of postcode of buyer 1's last settled accommodation,Part 2 of postcode of buyer 1's last settled accommodation,Do you know the local authority of buyer 1's last settled accommodation?,The local authority code of buyer 1's last settled accommodation,The local authority name of buyer 1's last settled accommodation,Was the buyer registered with their PRP (HA)?,Was the buyer registered with another PRP (HA)?,Was the buyer registered with the local authority?,Was the buyer registered with a Help to Buy agent?,"Populated if pregyrha, pregother, pregla and pregghb are blank","At the time of purchase, was buyer 2 living at the same address as buyer 1?",What was buyer 2's previous tenure?,Have any of the buyers ever served as a regular in the UK armed forces?,Is the buyer still serving in the UK armed forces?,Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,Is buyer 1's annual income known?,What is buyer 1's annual income?,Was buyer 1's income used for a mortgage application?,Is buyer 1's annual income known?,What is buyer 2's annual income?,Was buyer 2's income used for a mortgage application?,Were the buyers receiving any of these housing-related benefits immediately before buying this property?,Is the the total amount the buyers had in savings known?,What is the total amount the buyers had in savings before they paid any deposit for the property?,Have any of the buyers previously owned a property?,Was the previous property under shared ownership?,How long did the buyer(s) live in the property before purchasing it?,Is this a staircasing transaction?,What percentage of the property has been bought in this staircasing transaction?,What percentage of the property do the buyers now own in total?,Was this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?,Is this a resale?,Day of the exchange of contracts,Month of the exchange of contracts,Year of the exchange of contracts,Day of the practical completion or handover date,Month of the practical completion or handover date,Year of the practical completion or handover date,Was the household rehoused under a local authority nominations agreement?,"Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?",How many bedrooms did the buyer's previous property have?,What was the previous property type?,What was the rent type of buyer's previous tenure?,What is the full purchase price?,Populated if a soft validation is confirmed.,What was the initial percentage equity stake purchased?,Was a mortgage used to buy this property?,What is the mortgage amount?,What is the name of the mortgage lender?,"If mortgagelender = 'Other', what is the name of the mortgage lender?",What is the length of the mortgage in years?,Does this include any extra borrowing?,How much was the cash deposit paid on the property?,How much cash discount was given through Social Homebuy?,What is the basic monthly rent?,Does the property have any monthly leasehold charges?,What are the total monthly leasehold charges for the property?,Populated if a soft validation is confirmed.,What was the percentage discount?,"What was the amount of any loan, grant, discount or subsidy given?"
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,DAY,MONTH,YEAR,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
-,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,billyboy@eyeklaud.com,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,1,"1, Test Street",,Test Town,,AA1 1AA,Yes,Westminster,E09000033,,,Address line 1,SW1A 1AA,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,United Kingdom,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,AA1,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0
+,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,billyboy@eyeklaud.com,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,1,"1, Test Street",,Test Town,,AA1 1AA,Yes,Westminster,E09000033,1,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,United Kingdom,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0
diff --git a/spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv b/spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
index 0e9a781f5..a6eaed17a 100644
--- a/spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
+++ b/spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
@@ -1,3 +1,3 @@
Log ID,Status of log,ID of a set of duplicate logs,Time and date the log was created,Time and date the log was last updated,Year collection period opened,Was the log submitted in-service or via bulk upload?,,Is the user in the assigned_to column the data protection officer?,Day of sale completion date,Month of sale completion date,Year of sale completion date,Which organisation owned this property before the sale?,Which organisation reported the sale?,User the log is assigned to,What is the purchaser code?,Was this purchase made through an ownership scheme?,What is the type of shared ownership/discounted ownership/outright sale?,"If type = 'Other', what is the type of outright sale?",Is the buyer a company?,Will the buyer(s) live in the property?,Is this a joint purchase?,Are there more than 2 joint buyers of this property?,Did you interview the buyer to answer these questions?,Has the buyer seen the MHCLG privacy notice?,What is the UPRN of the property?,We found an address that might be this property. Is this the property address?,Address line 1 input from address matching feature,Postcode input from address matching feature,UPRN of the address selected,Address line 1,Address line 2,Town/City,County,Part 1 of the property's postcode,Part 2 of the property's postcode,LA code,LA name,How many bedrooms does the property have?,What type of unit is the property?,Which type of building is the property?,Is the property built or adapted to wheelchair-user standards?,What is buyer 1's age?,Which of these best describes buyer 1's gender identity?,What is buyer 1's ethnic group?,Which of the following best describes buyer 1's ethnic background?,What is buyer 1's nationality?,Which of these best describes buyer 1's working situation?,Will buyer 1 live in the property?,What is buyer 2 or person 2's relationship to buyer 1?,What is buyer 2 or person 2's age?,Which of these best describes buyer 2 or person 2's gender identity?,What is buyer 2's ethnic group?,Which of the following best describes buyer 2's ethnic background?,What is buyer 2's nationality?,What is buyer 2 or person 2's working situation?,Will buyer 2 live in the property?,"Besides the buyer(s), how many other people live or will live in the property?",What is person 3's relationship to buyer 1?,What is person 3's age?,What is person 3's gender identity?,What is person 3's working situation?,What is person 4's relationship to buyer 1?,What is person 4's age?,What is person 4's gender identity?,What is person 4's working situation?,What is person 5's relationship to buyer 1?,What is person 5's age?,What is person 5's gender identity?,What is person 5's working situation?,What is person 6's relationship to buyer 1?,What is person 6's age?,What is person 6's gender identity?,What is person 6's working situation?,What was buyer 1's previous tenure?,Do you know the postcode of buyer 1's last settled accommodation?,Part 1 of postcode of buyer 1's last settled accommodation,Part 2 of postcode of buyer 1's last settled accommodation,Do you know the local authority of buyer 1's last settled accommodation?,The local authority code of buyer 1's last settled accommodation,The local authority name of buyer 1's last settled accommodation,Was the buyer registered with their PRP (HA)?,Was the buyer registered with another PRP (HA)?,Was the buyer registered with the local authority?,Was the buyer registered with a Help to Buy agent?,"Populated if pregyrha, pregother, pregla and pregghb are blank","At the time of purchase, was buyer 2 living at the same address as buyer 1?",What was buyer 2's previous tenure?,Have any of the buyers ever served as a regular in the UK armed forces?,Is the buyer still serving in the UK armed forces?,Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,Is buyer 1's annual income known?,What is buyer 1's annual income?,Was buyer 1's income used for a mortgage application?,Is buyer 2's annual income known?,What is buyer 2's annual income?,Was buyer 2's income used for a mortgage application?,Were the buyers receiving any of these housing-related benefits immediately before buying this property?,Is the the total amount the buyers had in savings known?,What is the total amount the buyers had in savings before they paid any deposit for the property?,Have any of the buyers previously owned a property?,Was the previous property under shared ownership?,How long did the buyer(s) live in the property before purchasing it?,Is this a staircasing transaction?,What percentage of the property has been bought in this staircasing transaction?,What percentage of the property do the buyers now own in total?,Was this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?,Is this a resale?,Day of the exchange of contracts,Month of the exchange of contracts,Year of the exchange of contracts,Day of the practical completion or handover date,Month of the practical completion or handover date,Year of the practical completion or handover date,Was the household rehoused under a local authority nominations agreement?,"Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?",How many bedrooms did the buyer's previous property have?,What was the previous property type?,What was the rent type of buyer's previous tenure?,What is the full purchase price?,What was the initial percentage equity stake purchased?,Was a mortgage used to buy this property?,What is the mortgage amount?,What is the name of the mortgage lender?,"If mortgagelender = 'Other', what is the name of the mortgage lender?",What is the length of the mortgage in years?,Does this include any extra borrowing?,How much was the cash deposit paid on the property?,How much cash discount was given through Social Homebuy?,What is the basic monthly rent?,Does the property have any monthly leasehold charges?,What are the total monthly leasehold charges for the property?,What was the percentage discount?,"What was the amount of any loan, grant, discount or subsidy given?"
id,status,duplicate_set_id,created_at,updated_at,collection_start_year,creation_method,bulk_upload_id,is_dpo,day,month,year,owning_organisation_name,managing_organisation_name,assigned_to,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,beds,proptype,builtype,wchair,age1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
-,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,1,Yes,Address line 1,SW1A 1AA,,"1, Test Street",,Test Town,,AA1,1AA,E09000033,Westminster,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,United Kingdom,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,AA1,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0
+,completed,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,1,5,2024,MHCLG,MHCLG,billyboy@eyeklaud.com,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,1,Yes,,,1,"1, Test Street",,Test Town,,SW1A,1AA,E09000033,Westminster,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,United Kingdom,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0
diff --git a/spec/models/bulk_upload_spec.rb b/spec/models/bulk_upload_spec.rb
index 61e16920e..5195d23f4 100644
--- a/spec/models/bulk_upload_spec.rb
+++ b/spec/models/bulk_upload_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe BulkUpload, type: :model do
let(:log) { build(:lettings_log, startdate: Time.zone.local(2025, 4, 2), bulk_upload:) }
it "has the correct number of value checks to be set as confirmed" do
- expect(bulk_upload.fields_to_confirm(log)).to match_array %w[rent_value_check void_date_value_check major_repairs_date_value_check pregnancy_value_check retirement_value_check referral_value_check net_income_value_check scharge_value_check pscharge_value_check supcharg_value_check address_search_value_check multiple_partners_value_check partner_under_16_value_check reasonother_value_check]
+ expect(bulk_upload.fields_to_confirm(log)).to match_array %w[rent_value_check void_date_value_check major_repairs_date_value_check pregnancy_value_check retirement_value_check referral_value_check net_income_value_check scharge_value_check pscharge_value_check supcharg_value_check multiple_partners_value_check partner_under_16_value_check reasonother_value_check]
end
end
@@ -32,7 +32,7 @@ RSpec.describe BulkUpload, type: :model do
let(:log) { build(:sales_log, :saledate_today, bulk_upload:) }
it "has the correct number of value checks to be set as confirmed" do
- expect(bulk_upload.fields_to_confirm(log)).to match_array %w[value_value_check monthly_charges_value_check percentage_discount_value_check income1_value_check income2_value_check combined_income_value_check retirement_value_check old_persons_shared_ownership_value_check buyer_livein_value_check student_not_child_value_check wheel_value_check mortgage_value_check savings_value_check deposit_value_check staircase_bought_value_check stairowned_value_check hodate_check shared_ownership_deposit_value_check extrabor_value_check grant_value_check discounted_sale_value_check deposit_and_mortgage_value_check address_search_value_check multiple_partners_value_check partner_under_16_value_check]
+ expect(bulk_upload.fields_to_confirm(log)).to match_array %w[value_value_check monthly_charges_value_check percentage_discount_value_check income1_value_check income2_value_check combined_income_value_check retirement_value_check old_persons_shared_ownership_value_check buyer_livein_value_check student_not_child_value_check wheel_value_check mortgage_value_check savings_value_check deposit_value_check staircase_bought_value_check stairowned_value_check hodate_check shared_ownership_deposit_value_check extrabor_value_check grant_value_check discounted_sale_value_check deposit_and_mortgage_value_check multiple_partners_value_check partner_under_16_value_check]
end
end
end
diff --git a/spec/models/form/lettings/pages/address_fallback_spec.rb b/spec/models/form/lettings/pages/address_fallback_spec.rb
index d3971d540..ffac6238e 100644
--- a/spec/models/form/lettings/pages/address_fallback_spec.rb
+++ b/spec/models/form/lettings/pages/address_fallback_spec.rb
@@ -24,13 +24,6 @@ RSpec.describe Form::Lettings::Pages::AddressFallback, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([
- { "is_supported_housing?" => false, "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" },
- { "is_supported_housing?" => false, "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" },
- { "is_supported_housing?" => false, "uprn_confirmed" => 0, "uprn_selection" => "uprn_not_listed" },
- { "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => false },
- { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => false },
- { "is_supported_housing?" => false, "uprn_confirmed" => 0, "address_options_present?" => false },
- ])
+ expect(page.depends_on).to eq([{ "manual_address_entry_selected" => true, "is_supported_housing?" => false }])
end
end
diff --git a/spec/models/form/lettings/pages/address_search_spec.rb b/spec/models/form/lettings/pages/address_search_spec.rb
new file mode 100644
index 000000000..86c6537a1
--- /dev/null
+++ b/spec/models/form/lettings/pages/address_search_spec.rb
@@ -0,0 +1,42 @@
+require "rails_helper"
+
+RSpec.describe Form::Lettings::Pages::AddressSearch, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
+ let(:start_date) { Time.utc(2024, 4, 1) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[uprn])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("address_search")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to be_nil
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "is_supported_housing?" => false, "manual_address_entry_selected" => false }])
+ end
+
+ it "has the correct question number" do
+ expect(page.question_number).to eq(12)
+ end
+
+ context "with 2025/26 form" do
+ let(:start_date) { Time.utc(2025, 4, 1) }
+
+ it "has the correct question number" do
+ expect(page.question_number).to eq(16)
+ end
+ end
+end
diff --git a/spec/models/form/lettings/questions/address_search_spec.rb b/spec/models/form/lettings/questions/address_search_spec.rb
new file mode 100644
index 000000000..d063a94dc
--- /dev/null
+++ b/spec/models/form/lettings/questions/address_search_spec.rb
@@ -0,0 +1,68 @@
+require "rails_helper"
+
+RSpec.describe Form::Lettings::Questions::AddressSearch, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date:))) }
+ let(:start_date) { Time.utc(2024, 4, 1) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("uprn")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("address_search")
+ end
+
+ it "has the correct question number" do
+ expect(question.question_number).to eq(12)
+ end
+
+ context "with 2025/26 form" do
+ let(:start_date) { Time.utc(2025, 4, 1) }
+
+ it "has the correct question number" do
+ expect(question.question_number).to eq(16)
+ end
+ end
+
+ describe "get_extra_check_answer_value" do
+ context "when address is not present" do
+ let(:log) { build(:lettings_log, manual_address_entry_selected: false) }
+
+ it "returns nil" do
+ expect(question.get_extra_check_answer_value(log)).to be_nil
+ end
+ end
+
+ context "when address search is present" do
+ let(:log) do
+ build(
+ :lettings_log,
+ :completed,
+ address_line1: "19, Charlton Gardens",
+ town_or_city: "Bristol",
+ postcode_full: "BS10 6LU",
+ la: "E06000023",
+ uprn_known: 1,
+ uprn: 107,
+ uprn_confirmed: 1,
+ )
+ end
+
+ context "when uprn known" do
+ it "returns formatted value" do
+ expect(question.get_extra_check_answer_value(log)).to eq(
+ "\n\n19, Charlton Gardens\nBristol\nBS10 6LU\nBristol, City of",
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/form/lettings/questions/uprn_selection_spec.rb b/spec/models/form/lettings/questions/uprn_selection_spec.rb
index c3edc646e..e10b22d89 100644
--- a/spec/models/form/lettings/questions/uprn_selection_spec.rb
+++ b/spec/models/form/lettings/questions/uprn_selection_spec.rb
@@ -90,9 +90,10 @@ RSpec.describe Form::Lettings::Questions::UprnSelection, type: :model do
context "when the log has address line 1 input only" do
before do
+ allow(address_client_instance).to receive(:result).and_return(nil)
log.address_line1_input = "Address line 1"
log.postcode_full_input = nil
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
@@ -102,9 +103,10 @@ RSpec.describe Form::Lettings::Questions::UprnSelection, type: :model do
context "when the log has postcode input only" do
before do
+ allow(address_client_instance).to receive(:result).and_return(nil)
log.address_line1_input = nil
log.postcode_full_input = "A1 1AA"
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
@@ -116,7 +118,7 @@ RSpec.describe Form::Lettings::Questions::UprnSelection, type: :model do
before do
log.address_line1_input = "Address line 1"
log.postcode_full_input = "A1 1AA"
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
diff --git a/spec/models/form/lettings/questions/uprn_spec.rb b/spec/models/form/lettings/questions/uprn_spec.rb
index 8bb932b35..0c3ecec85 100644
--- a/spec/models/form/lettings/questions/uprn_spec.rb
+++ b/spec/models/form/lettings/questions/uprn_spec.rb
@@ -52,12 +52,14 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
la: "E09000003",
uprn_known:,
uprn:,
+ manual_address_entry_selected:,
)
end
context "when uprn known nil" do
let(:uprn_known) { nil }
let(:uprn) { nil }
+ let(:manual_address_entry_selected) { true }
it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil
@@ -67,6 +69,7 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
context "when uprn known" do
let(:uprn_known) { 1 }
let(:uprn) { 1 }
+ let(:manual_address_entry_selected) { false }
it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to eq(
@@ -78,6 +81,7 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
context "when uprn not known" do
let(:uprn_known) { 0 }
let(:uprn) { nil }
+ let(:manual_address_entry_selected) { true }
it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil
diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb
index e0e9a61ae..2630c83d4 100644
--- a/spec/models/form/lettings/subsections/property_information_spec.rb
+++ b/spec/models/form/lettings/subsections/property_information_spec.rb
@@ -64,11 +64,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- uprn
- uprn_confirmation
- address_matcher
- no_address_found
- uprn_selection
+ address_search
address
property_local_authority
local_authority_rent_value_check
@@ -105,11 +101,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_let_type
property_vacancy_reason_not_first_let
property_vacancy_reason_first_let
- uprn
- uprn_confirmation
- address_matcher
- no_address_found
- uprn_selection
+ address_search
address
property_local_authority
local_authority_rent_value_check
diff --git a/spec/models/form/sales/pages/address_fallback_spec.rb b/spec/models/form/sales/pages/address_fallback_spec.rb
index 4c48a46fe..35bb6cd24 100644
--- a/spec/models/form/sales/pages/address_fallback_spec.rb
+++ b/spec/models/form/sales/pages/address_fallback_spec.rb
@@ -24,13 +24,6 @@ RSpec.describe Form::Sales::Pages::AddressFallback, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([
- { "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" },
- { "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" },
- { "uprn_confirmed" => 0, "uprn_selection" => "uprn_not_listed" },
- { "uprn_known" => nil, "address_options_present?" => false },
- { "uprn_known" => 0, "address_options_present?" => false },
- { "uprn_confirmed" => 0, "address_options_present?" => false },
- ])
+ expect(page.depends_on).to eq([{ "manual_address_entry_selected" => true }])
end
end
diff --git a/spec/models/form/sales/pages/address_search_spec.rb b/spec/models/form/sales/pages/address_search_spec.rb
new file mode 100644
index 000000000..670854694
--- /dev/null
+++ b/spec/models/form/sales/pages/address_search_spec.rb
@@ -0,0 +1,42 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::AddressSearch, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
+ let(:start_date) { Time.utc(2024, 4, 1) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[uprn])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("address_search")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to be_nil
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "manual_address_entry_selected" => false }])
+ end
+
+ it "has the correct question number" do
+ expect(page.question_number).to eq(15)
+ end
+
+ context "with 2025/26 form" do
+ let(:start_date) { Time.utc(2025, 4, 1) }
+
+ it "has the correct question number" do
+ expect(page.question_number).to eq(13)
+ end
+ end
+end
diff --git a/spec/models/form/sales/pages/uprn_confirmation_spec.rb b/spec/models/form/sales/pages/uprn_confirmation_spec.rb
index 9550b9f49..6415c2eb0 100644
--- a/spec/models/form/sales/pages/uprn_confirmation_spec.rb
+++ b/spec/models/form/sales/pages/uprn_confirmation_spec.rb
@@ -7,6 +7,10 @@ RSpec.describe Form::Sales::Pages::UprnConfirmation, type: :model do
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
+ before do
+ allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false))
+ end
+
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
diff --git a/spec/models/form/sales/questions/address_search_spec.rb b/spec/models/form/sales/questions/address_search_spec.rb
new file mode 100644
index 000000000..bb30cbfa0
--- /dev/null
+++ b/spec/models/form/sales/questions/address_search_spec.rb
@@ -0,0 +1,68 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::AddressSearch, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date:))) }
+ let(:start_date) { Time.utc(2024, 4, 1) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("uprn")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("address_search")
+ end
+
+ it "has the correct question number" do
+ expect(question.question_number).to eq(15)
+ end
+
+ context "with 2025/26 form" do
+ let(:start_date) { Time.utc(2025, 4, 1) }
+
+ it "has the correct question number" do
+ expect(question.question_number).to eq(13)
+ end
+ end
+
+ describe "get_extra_check_answer_value" do
+ context "when address is not present" do
+ let(:log) { build(:sales_log, manual_address_entry_selected: false) }
+
+ it "returns nil" do
+ expect(question.get_extra_check_answer_value(log)).to be_nil
+ end
+ end
+
+ context "when address search is present" do
+ let(:log) do
+ build(
+ :sales_log,
+ :completed,
+ address_line1: "19, Charlton Gardens",
+ town_or_city: "Bristol",
+ postcode_full: "BS10 6LU",
+ la: "E06000023",
+ uprn_known: 1,
+ uprn: 107,
+ uprn_confirmed: 1,
+ )
+ end
+
+ context "when uprn known" do
+ it "returns formatted value" do
+ expect(question.get_extra_check_answer_value(log)).to eq(
+ "\n\n19, Charlton Gardens\nBristol\nBS10 6LU\nBristol, City of",
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/form/sales/questions/uprn_selection_spec.rb b/spec/models/form/sales/questions/uprn_selection_spec.rb
index ff1b1a6dd..efcf39c67 100644
--- a/spec/models/form/sales/questions/uprn_selection_spec.rb
+++ b/spec/models/form/sales/questions/uprn_selection_spec.rb
@@ -90,9 +90,10 @@ RSpec.describe Form::Sales::Questions::UprnSelection, type: :model do
context "when the log has address line 1 input only" do
before do
+ allow(address_client_instance).to receive(:result).and_return(nil)
log.address_line1_input = "Address line 1"
log.postcode_full_input = nil
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
@@ -102,9 +103,10 @@ RSpec.describe Form::Sales::Questions::UprnSelection, type: :model do
context "when the log has postcode input only" do
before do
+ allow(address_client_instance).to receive(:result).and_return(nil)
log.address_line1_input = nil
log.postcode_full_input = "A1 1AA"
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
@@ -116,7 +118,7 @@ RSpec.describe Form::Sales::Questions::UprnSelection, type: :model do
before do
log.address_line1_input = "Address line 1"
log.postcode_full_input = "A1 1AA"
- log.save!(valudate: false)
+ log.save!(validate: false)
end
it "has the correct input_playback" do
diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb
index ccfeb8e3a..7585d290a 100644
--- a/spec/models/form/sales/subsections/property_information_spec.rb
+++ b/spec/models/form/sales/subsections/property_information_spec.rb
@@ -55,11 +55,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- uprn
- uprn_confirmation
- address_matcher
- no_address_found
- uprn_selection
+ address_search
address
property_local_authority
local_authority_buyer_1_income_max_value_check
@@ -89,11 +85,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- uprn
- uprn_confirmation
- address_matcher
- no_address_found
- uprn_selection
+ address_search
address
property_local_authority
local_authority_buyer_1_income_max_value_check
diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb
index c36884b8d..442febddb 100644
--- a/spec/models/sales_log_spec.rb
+++ b/spec/models/sales_log_spec.rb
@@ -566,6 +566,7 @@ RSpec.describe SalesLog, type: :model do
ppostcode_full: nil,
prevloc: nil,
saledate: Time.zone.local(2024, 5, 2),
+ manual_address_entry_selected: true,
})
end
@@ -617,7 +618,7 @@ RSpec.describe SalesLog, type: :model do
end
let(:address_sales_log_25_26) do
- create(:sales_log, :shared_ownership_setup_complete, postcode_full: "CA10 1AA", saledate: Time.zone.local(2025, 5, 2))
+ create(:sales_log, :shared_ownership_setup_complete, postcode_full: "CA10 1AA", saledate: Time.zone.local(2025, 5, 2), manual_address_entry_selected: true)
end
before do
@@ -672,11 +673,11 @@ RSpec.describe SalesLog, type: :model do
context "when saving address with LAs that have changed E-codes" do
context "when address inferred from uprn - we still get LA from postcode" do
let(:address_sales_log_24_25) do
- create(:sales_log, :shared_ownership_setup_complete, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2024, 5, 2))
+ create(:sales_log, :shared_ownership_setup_complete, manual_address_entry_selected: false, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2024, 5, 2))
end
let(:address_sales_log_25_26) do
- create(:sales_log, :shared_ownership_setup_complete, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2025, 5, 2))
+ create(:sales_log, :shared_ownership_setup_complete, manual_address_entry_selected: false, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2025, 5, 2))
end
before do
diff --git a/spec/models/validations/sales/property_validations_spec.rb b/spec/models/validations/sales/property_validations_spec.rb
index c5af3ae78..62b65ee36 100644
--- a/spec/models/validations/sales/property_validations_spec.rb
+++ b/spec/models/validations/sales/property_validations_spec.rb
@@ -136,9 +136,9 @@ RSpec.describe Validations::Sales::PropertyValidations do
context "when within the limit and only numeric" do
let(:record) { build(:sales_log, uprn: "123456789012") }
- it "does not add an error" do
+ it "does not add an invalid UPRN error" do
property_validator.validate_uprn(record)
- expect(record.errors).not_to be_present
+ expect(record.errors.added?(:uprn, I18n.t("validations.sales.property_information.uprn.invalid"))).to be false
end
end
end
diff --git a/spec/request_helper.rb b/spec/request_helper.rb
index f1f208ec6..2e0cc3d70 100644
--- a/spec/request_helper.rb
+++ b/spec/request_helper.rb
@@ -20,7 +20,7 @@ module RequestHelper
body = { results: [{ DPA: { UPRN: "10033558653" } }] }.to_json
WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?key&maxresults=10&minmatch=0.4&query=Address%20line%201,%20SW1A%201AA")
.to_return(status: 200, body:, headers: {})
- body = { results: [{ DPA: { "POSTCODE": "SW1A 1AA", "POST_TOWN": "London" } }] }.to_json
+ body = { results: [{ DPA: { "POSTCODE": "SW1A 1AA", "POST_TOWN": "London", "PO_BOX_NUMBER": "The Mall, City Of Westminster" } }] }.to_json
WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key&uprn=1")
.to_return(status: 200, body:, headers: {})
WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key&uprn=10033558653")
diff --git a/spec/requests/address_search_controller_spec.rb b/spec/requests/address_search_controller_spec.rb
new file mode 100644
index 000000000..5c2acd11a
--- /dev/null
+++ b/spec/requests/address_search_controller_spec.rb
@@ -0,0 +1,148 @@
+require "rails_helper"
+
+RSpec.describe AddressSearchController, type: :request do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in user
+ end
+
+ describe "#manual input" do
+ context "when no address data is given and user chooses to enter address manually" do
+ let(:sales_log) { create(:sales_log, :shared_ownership_setup_complete, manual_address_entry_selected: false, assigned_to: user) }
+
+ it "correctly sets address fields" do
+ sales_log.reload
+ expect(sales_log.manual_address_entry_selected).to eq(false)
+ expect(sales_log.uprn_known).to eq(nil)
+ expect(sales_log.uprn).to eq(nil)
+ expect(sales_log.uprn_confirmed).to eq(nil)
+ expect(sales_log.uprn_selection).to eq(nil)
+ expect(sales_log.pcodenk).to eq(nil)
+ expect(sales_log.postcode_full).to eq(nil)
+ expect(sales_log.address_line1).to eq(nil)
+ expect(sales_log.address_line2).to eq(nil)
+ expect(sales_log.town_or_city).to eq(nil)
+ expect(sales_log.la).to eq(nil)
+
+ get "/address-search/manual-input/sales_log/#{sales_log.id}"
+
+ sales_log.reload
+ expect(sales_log.manual_address_entry_selected).to eq(true)
+ expect(sales_log.uprn_known).to eq(0)
+ expect(sales_log.uprn).to eq(nil)
+ expect(sales_log.uprn_confirmed).to eq(nil)
+ expect(sales_log.uprn_selection).to eq(nil)
+ expect(sales_log.pcodenk).to eq(nil)
+ expect(sales_log.postcode_full).to eq(nil)
+ expect(sales_log.address_line1).to eq(nil)
+ expect(sales_log.address_line2).to eq(nil)
+ expect(sales_log.town_or_city).to eq(nil)
+ expect(sales_log.la).to eq(nil)
+ end
+ end
+
+ context "when choosing to manually input an address for a log that has an address searched value" do
+ let(:lettings_log) { create(:lettings_log, :completed, manual_address_entry_selected: false, assigned_to: user) }
+
+ it "correctly sets address fields" do
+ lettings_log.reload
+ expect(lettings_log.uprn_known).to eq(1)
+ expect(lettings_log.uprn).to eq("10033558653")
+ expect(lettings_log.uprn_confirmed).to eq(1)
+ expect(lettings_log.uprn_selection).to eq("10033558653")
+ expect(lettings_log.postcode_known).to eq(1)
+ expect(lettings_log.postcode_full).to eq("SW1A 1AA")
+ expect(lettings_log.address_line1).to eq("The Mall, City Of Westminster")
+ expect(lettings_log.address_line2).to eq(nil)
+ expect(lettings_log.town_or_city).to eq("London")
+ expect(lettings_log.la).to eq("E09000033")
+
+ get "/address-search/manual-input/lettings_log/#{lettings_log.id}"
+
+ lettings_log.reload
+ expect(lettings_log.manual_address_entry_selected).to eq(true)
+ expect(lettings_log.uprn_known).to eq(0)
+ expect(lettings_log.uprn).to eq(nil)
+ expect(lettings_log.uprn_confirmed).to eq(nil)
+ expect(lettings_log.uprn_selection).to eq(nil)
+ expect(lettings_log.postcode_known).to eq(nil)
+ expect(lettings_log.postcode_full).to eq(nil)
+ expect(lettings_log.address_line1).to eq(nil)
+ expect(lettings_log.address_line2).to eq(nil)
+ expect(lettings_log.town_or_city).to eq(nil)
+ expect(lettings_log.la).to eq(nil)
+ end
+ end
+ end
+
+ describe "#search input" do
+ context "when no address is entered manually and choosing to search instead" do
+ let(:lettings_log) { create(:lettings_log, :setup_completed, manual_address_entry_selected: true, assigned_to: user) }
+
+ it "correctly sets address fields" do
+ lettings_log.reload
+ expect(lettings_log.manual_address_entry_selected).to eq(true)
+ expect(lettings_log.uprn_known).to eq(0)
+ expect(lettings_log.uprn).to eq(nil)
+ expect(lettings_log.uprn_confirmed).to eq(nil)
+ expect(lettings_log.uprn_selection).to eq(nil)
+ expect(lettings_log.postcode_known).to eq(nil)
+ expect(lettings_log.postcode_full).to eq(nil)
+ expect(lettings_log.address_line1).to eq(nil)
+ expect(lettings_log.address_line2).to eq(nil)
+ expect(lettings_log.town_or_city).to eq(nil)
+ expect(lettings_log.la).to eq(nil)
+
+ get "/address-search/search-input/lettings_log/#{lettings_log.id}"
+
+ lettings_log.reload
+ expect(lettings_log.manual_address_entry_selected).to eq(false)
+ expect(lettings_log.uprn_known).to eq(nil)
+ expect(lettings_log.uprn).to eq(nil)
+ expect(lettings_log.uprn_confirmed).to eq(nil)
+ expect(lettings_log.uprn_selection).to eq(nil)
+ expect(lettings_log.postcode_known).to eq(nil)
+ expect(lettings_log.postcode_full).to eq(nil)
+ expect(lettings_log.address_line1).to eq(nil)
+ expect(lettings_log.address_line2).to eq(nil)
+ expect(lettings_log.town_or_city).to eq(nil)
+ expect(lettings_log.la).to eq(nil)
+ end
+ end
+
+ context "when choosing to search for an address for a log that has an address searched value" do
+ let(:sales_log) { create(:sales_log, :completed, manual_address_entry_selected: true, town_or_city: "Test Town", assigned_to: user) }
+
+ it "correctly sets address fields" do
+ sales_log.reload
+ expect(sales_log.manual_address_entry_selected).to eq(true)
+ expect(sales_log.uprn_known).to eq(0)
+ expect(sales_log.uprn).to eq(nil)
+ expect(sales_log.uprn_confirmed).to eq(nil)
+ expect(sales_log.uprn_selection).to eq(nil)
+ expect(sales_log.pcodenk).to eq(0)
+ expect(sales_log.postcode_full).to eq("SW1A 1AA")
+ expect(sales_log.address_line1).to eq("Address line 1")
+ expect(sales_log.address_line2).to eq(nil)
+ expect(sales_log.town_or_city).to eq("Test Town")
+ expect(sales_log.la).to eq("E09000033")
+
+ get "/address-search/search-input/sales_log/#{sales_log.id}"
+
+ sales_log.reload
+ expect(sales_log.manual_address_entry_selected).to eq(false)
+ expect(sales_log.uprn_known).to eq(nil)
+ expect(sales_log.uprn).to eq(nil)
+ expect(sales_log.uprn_confirmed).to eq(nil)
+ expect(sales_log.uprn_selection).to eq(nil)
+ expect(sales_log.pcodenk).to eq(nil)
+ expect(sales_log.postcode_full).to eq(nil)
+ expect(sales_log.address_line1).to eq(nil)
+ expect(sales_log.address_line2).to eq(nil)
+ expect(sales_log.town_or_city).to eq(nil)
+ expect(sales_log.la).to eq(nil)
+ end
+ end
+ end
+end
diff --git a/spec/requests/duplicate_logs_controller_spec.rb b/spec/requests/duplicate_logs_controller_spec.rb
index 700964fcf..c2c05e748 100644
--- a/spec/requests/duplicate_logs_controller_spec.rb
+++ b/spec/requests/duplicate_logs_controller_spec.rb
@@ -77,8 +77,8 @@ RSpec.describe DuplicateLogsController, type: :request do
end
it "displays check your answers for each log with correct questions where UPRN is given" do
- lettings_log.update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1)
- duplicate_logs[0].update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1)
+ lettings_log.update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1, manual_address_entry_selected: false)
+ duplicate_logs[0].update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1, manual_address_entry_selected: false)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}"
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
@@ -186,9 +186,9 @@ RSpec.describe DuplicateLogsController, type: :request do
end
it "displays check your answers for each log with correct questions when UPRN is given" do
- sales_log.update!(uprn: "123", uprn_known: 1)
- duplicate_logs[0].update!(uprn: "123", uprn_known: 1)
- duplicate_logs[1].update!(uprn: "123", uprn_known: 1)
+ sales_log.update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
+ duplicate_logs[0].update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
+ duplicate_logs[1].update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}"
expect(page).to have_content("Q1 - Sale completion date", count: 3)
diff --git a/spec/services/csv/sales_log_csv_service_spec.rb b/spec/services/csv/sales_log_csv_service_spec.rb
index 3cf56af2e..5e041b2d5 100644
--- a/spec/services/csv/sales_log_csv_service_spec.rb
+++ b/spec/services/csv/sales_log_csv_service_spec.rb
@@ -199,7 +199,7 @@ RSpec.describe Csv::SalesLogCsvService do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
before do
- log.update!(nationality_all: 36)
+ log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
end
it "exports the CSV with the 2024 ordering and all values correct" do
@@ -286,6 +286,10 @@ RSpec.describe Csv::SalesLogCsvService do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
let(:year) { 2024 }
+ before do
+ log.update!(manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
+ end
+
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_24.csv")
values_to_delete = %w[ID]
@@ -338,7 +342,7 @@ RSpec.describe Csv::SalesLogCsvService do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
before do
- log.update!(nationality_all: 36)
+ log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
end
context "and exporting with labels" do
diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb
index 1db9cf4d9..12e3809f0 100644
--- a/spec/services/exports/lettings_log_export_service_spec.rb
+++ b/spec/services/exports/lettings_log_export_service_spec.rb
@@ -431,7 +431,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, creation_method: 2, bulk_upload_id: 1, address_line1_as_entered: "address line 1 as entered", address_line2_as_entered: "address line 2 as entered", town_or_city_as_entered: "town or city as entered", county_as_entered: "county as entered", postcode_full_as_entered: "AB1 2CD", la_as_entered: "la as entered") }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, creation_method: 2, bulk_upload_id: 1, address_line1_as_entered: "address line 1 as entered", address_line2_as_entered: "address line 2 as entered", town_or_city_as_entered: "town or city as entered", county_as_entered: "county as entered", postcode_full_as_entered: "AB1 2CD", la_as_entered: "la as entered", manual_address_entry_selected: false, uprn: "1", uprn_known: 1) }
let(:expected_zip_filename) { "core_2024_2025_apr_mar_f0001_inc0001.zip" }
let(:expected_data_filename) { "core_2024_2025_apr_mar_f0001_inc0001_pt001.xml" }
let(:xml_export_file) { File.open("spec/fixtures/exports/general_needs_log_24_25.xml", "r:UTF-8") }
diff --git a/spec/shared/shared_examples_for_derived_fields.rb b/spec/shared/shared_examples_for_derived_fields.rb
index 3e6b685df..3f746468a 100644
--- a/spec/shared/shared_examples_for_derived_fields.rb
+++ b/spec/shared/shared_examples_for_derived_fields.rb
@@ -25,11 +25,14 @@ RSpec.shared_examples "shared examples for derived fields" do |log_type|
end
it "does not affect older logs with uprn_confirmed == 0" do
- log = FactoryBot.build(log_type, uprn_known: 0, uprn: nil, uprn_confirmed: 0)
-
- expect { log.set_derived_fields! }.to not_change(log, :uprn_known)
- .and not_change(log, :uprn)
- .and not_change(log, :uprn_confirmed)
+ Timecop.freeze(Time.zone.local(2023, 4, 1)) do
+ log = FactoryBot.build(log_type, uprn_known: 0, uprn: nil, uprn_confirmed: 0)
+ allow(log.form).to receive(:start_year_2024_or_later?).and_return(false)
+ expect { log.set_derived_fields! }.to not_change(log, :uprn_known)
+ .and not_change(log, :uprn)
+ .and not_change(log, :uprn_confirmed)
+ end
+ Timecop.return
end
end
end
diff --git a/spec/shared/shared_log_examples.rb b/spec/shared/shared_log_examples.rb
index ef9ba32e6..77be654d7 100644
--- a/spec/shared/shared_log_examples.rb
+++ b/spec/shared/shared_log_examples.rb
@@ -81,7 +81,6 @@ RSpec.shared_examples "shared log examples" do |log_type|
expect { log.process_uprn_change! }.to change(log, :address_line1).from(nil).to("0, Building Name, Thoroughfare")
.and change(log, :town_or_city).from(nil).to("Posttown")
.and change(log, :postcode_full).from(nil).to("POSTCODE")
- .and change(log, :uprn_confirmed).from(1).to(nil)
.and change(log, :county).from("county").to(nil)
end
end
@@ -156,7 +155,6 @@ RSpec.shared_examples "shared log examples" do |log_type|
.and change(log, :uprn_confirmed).from(nil).to(1)
.and change(log, :uprn).from(nil).to("UPRN")
.and change(log, :uprn_known).from(nil).to(1)
- .and change(log, :uprn_selection).from("UPRN").to(nil)
.and change(log, :county).from("county").to(nil)
end
end