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,11 +60,4 @@ 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
-
"
+ "
\ No newline at end of file
diff --git a/config/locales/forms/2024/lettings/property_information.en.yml b/config/locales/forms/2024/lettings/property_information.en.yml
index 016c78958..9e7326040 100644
--- a/config/locales/forms/2024/lettings/property_information.en.yml
+++ b/config/locales/forms/2024/lettings/property_information.en.yml
@@ -50,13 +50,6 @@ 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 b57595c66..801c43a5c 100644
--- a/config/locales/forms/2024/sales/guidance.en.yml
+++ b/config/locales/forms/2024/sales/guidance.en.yml
@@ -44,10 +44,3 @@ 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 518654211..b40e40267 100644
--- a/config/locales/forms/2024/sales/property_information.en.yml
+++ b/config/locales/forms/2024/sales/property_information.en.yml
@@ -43,13 +43,6 @@ 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 cb51fbf9d..340eb11d5 100644
--- a/config/locales/forms/2025/lettings/guidance.en.yml
+++ b/config/locales/forms/2025/lettings/guidance.en.yml
@@ -61,10 +61,3 @@ 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 41cf2d3aa..22a0d12db 100644
--- a/config/locales/forms/2025/lettings/property_information.en.yml
+++ b/config/locales/forms/2025/lettings/property_information.en.yml
@@ -10,12 +10,45 @@ en:
hint_text: ""
question_text: "Is this the first time the property has been let as social housing?"
- 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"
+ 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:
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 cfb9b0615..4ed6796b3 100644
--- a/config/locales/forms/2025/sales/guidance.en.yml
+++ b/config/locales/forms/2025/sales/guidance.en.yml
@@ -44,10 +44,3 @@ 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 e91089bc5..332219a6b 100644
--- a/config/locales/forms/2025/sales/property_information.en.yml
+++ b/config/locales/forms/2025/sales/property_information.en.yml
@@ -3,12 +3,45 @@ en:
2025:
sales:
property_information:
- 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"
+ 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:
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 f421177af..9014f1d78 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 create logs for sales in England."
+ not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur 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 entered an address outside of England. Only create logs for sales in England."
+ not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings 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 sales in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
uprn_confirmation:
- not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
uprn_selection:
- not_in_england: "It looks like you have entered an address outside of England. Only create logs for sales in England."
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
saledate:
- 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."
+ 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."
diff --git a/config/routes.rb b/config/routes.rb
index 304d54ef0..471c89578 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -39,10 +39,6 @@ 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
deleted file mode 100644
index a0d0f7529..000000000
--- a/db/migrate/20250219122817_add_manual_address_entry_selected_to_logs.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-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 f041f506e..894bb1638 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.2].define(version: 2025_02_19_122817) do
+ActiveRecord::Schema[7.2].define(version: 2025_01_10_150609) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -373,7 +373,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_19_122817) do
t.integer "partner_under_16_value_check"
t.integer "multiple_partners_value_check"
t.bigint "created_by_id"
- t.boolean "manual_address_entry_selected", default: false
t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id"
@@ -770,7 +769,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_19_122817) 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 1581527d0..c8c51ecf3 100644
--- a/spec/factories/lettings_log.rb
+++ b/spec/factories/lettings_log.rb
@@ -6,7 +6,6 @@ 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,11 +166,13 @@ 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 = evaluator.uprn || "10033558653"
- log.uprn_selection = evaluator.uprn_selection || "10033558653"
+ log.uprn = "10033558653"
+ log.uprn_selection = 1
end
end
end
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 64137704c..820c99fdc 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -8,8 +8,6 @@ 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 }
@@ -168,12 +166,14 @@ 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 = evaluator.uprn || "10033558653"
- log.uprn_selection = evaluator.uprn_selection || "10033558653"
+ log.uprn = "10033558653"
+ log.uprn_selection = 1
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
deleted file mode 100644
index cd1738195..000000000
--- a/spec/features/form/address_search_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-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 695115a78..6484fe94c 100644
--- a/spec/features/form/form_navigation_spec.rb
+++ b/spec/features/form/form_navigation_spec.rb
@@ -186,4 +186,64 @@ 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 15d24e5ed..a400ef2d0 100644
--- a/spec/features/lettings_log_spec.rb
+++ b/spec/features/lettings_log_spec.rb
@@ -729,5 +729,380 @@ 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 3fa89a504..3030d6d6a 100644
--- a/spec/features/sales_log_spec.rb
+++ b/spec/features/sales_log_spec.rb
@@ -334,6 +334,381 @@ 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 f874e4e75..e0ebccb38 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,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
+,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
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 a66a16201..ffda37642 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,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
+,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
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 a6eaed17a..0e9a781f5 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,,,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
+,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
diff --git a/spec/models/bulk_upload_spec.rb b/spec/models/bulk_upload_spec.rb
index 5195d23f4..61e16920e 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 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 address_search_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 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 address_search_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 ffac6238e..d3971d540 100644
--- a/spec/models/form/lettings/pages/address_fallback_spec.rb
+++ b/spec/models/form/lettings/pages/address_fallback_spec.rb
@@ -24,6 +24,13 @@ RSpec.describe Form::Lettings::Pages::AddressFallback, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([{ "manual_address_entry_selected" => true, "is_supported_housing?" => false }])
+ 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 },
+ ])
end
end
diff --git a/spec/models/form/lettings/pages/address_search_spec.rb b/spec/models/form/lettings/pages/address_search_spec.rb
deleted file mode 100644
index 86c6537a1..000000000
--- a/spec/models/form/lettings/pages/address_search_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644
index d063a94dc..000000000
--- a/spec/models/form/lettings/questions/address_search_spec.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-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 e10b22d89..c3edc646e 100644
--- a/spec/models/form/lettings/questions/uprn_selection_spec.rb
+++ b/spec/models/form/lettings/questions/uprn_selection_spec.rb
@@ -90,10 +90,9 @@ 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!(validate: false)
+ log.save!(valudate: false)
end
it "has the correct input_playback" do
@@ -103,10 +102,9 @@ 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!(validate: false)
+ log.save!(valudate: false)
end
it "has the correct input_playback" do
@@ -118,7 +116,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!(validate: false)
+ log.save!(valudate: 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 0c3ecec85..8bb932b35 100644
--- a/spec/models/form/lettings/questions/uprn_spec.rb
+++ b/spec/models/form/lettings/questions/uprn_spec.rb
@@ -52,14 +52,12 @@ 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
@@ -69,7 +67,6 @@ 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(
@@ -81,7 +78,6 @@ 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 e2b4b701a..0d3a4e99b 100644
--- a/spec/models/form/lettings/subsections/property_information_spec.rb
+++ b/spec/models/form/lettings/subsections/property_information_spec.rb
@@ -64,7 +64,11 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- address_search
+ uprn
+ uprn_confirmation
+ address_matcher
+ no_address_found
+ uprn_selection
address
property_local_authority
local_authority_rent_value_check
@@ -97,7 +101,11 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- address_search
+ uprn
+ uprn_confirmation
+ address_matcher
+ no_address_found
+ uprn_selection
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 35bb6cd24..4c48a46fe 100644
--- a/spec/models/form/sales/pages/address_fallback_spec.rb
+++ b/spec/models/form/sales/pages/address_fallback_spec.rb
@@ -24,6 +24,13 @@ RSpec.describe Form::Sales::Pages::AddressFallback, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([{ "manual_address_entry_selected" => true }])
+ 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 },
+ ])
end
end
diff --git a/spec/models/form/sales/pages/address_search_spec.rb b/spec/models/form/sales/pages/address_search_spec.rb
deleted file mode 100644
index 670854694..000000000
--- a/spec/models/form/sales/pages/address_search_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-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 6415c2eb0..9550b9f49 100644
--- a/spec/models/form/sales/pages/uprn_confirmation_spec.rb
+++ b/spec/models/form/sales/pages/uprn_confirmation_spec.rb
@@ -7,10 +7,6 @@ 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
deleted file mode 100644
index bb30cbfa0..000000000
--- a/spec/models/form/sales/questions/address_search_spec.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-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 efcf39c67..ff1b1a6dd 100644
--- a/spec/models/form/sales/questions/uprn_selection_spec.rb
+++ b/spec/models/form/sales/questions/uprn_selection_spec.rb
@@ -90,10 +90,9 @@ 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!(validate: false)
+ log.save!(valudate: false)
end
it "has the correct input_playback" do
@@ -103,10 +102,9 @@ 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!(validate: false)
+ log.save!(valudate: false)
end
it "has the correct input_playback" do
@@ -118,7 +116,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!(validate: false)
+ log.save!(valudate: 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 7585d290a..ccfeb8e3a 100644
--- a/spec/models/form/sales/subsections/property_information_spec.rb
+++ b/spec/models/form/sales/subsections/property_information_spec.rb
@@ -55,7 +55,11 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- address_search
+ uprn
+ uprn_confirmation
+ address_matcher
+ no_address_found
+ uprn_selection
address
property_local_authority
local_authority_buyer_1_income_max_value_check
@@ -85,7 +89,11 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[
- address_search
+ uprn
+ uprn_confirmation
+ address_matcher
+ no_address_found
+ uprn_selection
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 442febddb..c36884b8d 100644
--- a/spec/models/sales_log_spec.rb
+++ b/spec/models/sales_log_spec.rb
@@ -566,7 +566,6 @@ RSpec.describe SalesLog, type: :model do
ppostcode_full: nil,
prevloc: nil,
saledate: Time.zone.local(2024, 5, 2),
- manual_address_entry_selected: true,
})
end
@@ -618,7 +617,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), manual_address_entry_selected: true)
+ create(:sales_log, :shared_ownership_setup_complete, postcode_full: "CA10 1AA", saledate: Time.zone.local(2025, 5, 2))
end
before do
@@ -673,11 +672,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, manual_address_entry_selected: false, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2024, 5, 2))
+ create(:sales_log, :shared_ownership_setup_complete, 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, manual_address_entry_selected: false, uprn_known: 1, uprn: 1, saledate: Time.zone.local(2025, 5, 2))
+ create(:sales_log, :shared_ownership_setup_complete, 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 62b65ee36..c5af3ae78 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 invalid UPRN error" do
+ it "does not add an error" do
property_validator.validate_uprn(record)
- expect(record.errors.added?(:uprn, I18n.t("validations.sales.property_information.uprn.invalid"))).to be false
+ expect(record.errors).not_to be_present
end
end
end
diff --git a/spec/request_helper.rb b/spec/request_helper.rb
index 2e0cc3d70..f1f208ec6 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", "PO_BOX_NUMBER": "The Mall, City Of Westminster" } }] }.to_json
+ body = { results: [{ DPA: { "POSTCODE": "SW1A 1AA", "POST_TOWN": "London" } }] }.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
deleted file mode 100644
index 5c2acd11a..000000000
--- a/spec/requests/address_search_controller_spec.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-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 c2c05e748..700964fcf 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, manual_address_entry_selected: false)
- duplicate_logs[0].update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1, manual_address_entry_selected: false)
+ lettings_log.update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1)
+ duplicate_logs[0].update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1)
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, 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)
+ 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)
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 5e041b2d5..3cf56af2e 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, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
+ log.update!(nationality_all: 36)
end
it "exports the CSV with the 2024 ordering and all values correct" do
@@ -286,10 +286,6 @@ 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]
@@ -342,7 +338,7 @@ RSpec.describe Csv::SalesLogCsvService do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
before do
- log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
+ log.update!(nationality_all: 36)
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 12e3809f0..1db9cf4d9 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", manual_address_entry_selected: false, uprn: "1", uprn_known: 1) }
+ 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(: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 3f746468a..3e6b685df 100644
--- a/spec/shared/shared_examples_for_derived_fields.rb
+++ b/spec/shared/shared_examples_for_derived_fields.rb
@@ -25,14 +25,11 @@ RSpec.shared_examples "shared examples for derived fields" do |log_type|
end
it "does not affect older logs with uprn_confirmed == 0" do
- 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
+ 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)
end
end
end
diff --git a/spec/shared/shared_log_examples.rb b/spec/shared/shared_log_examples.rb
index 77be654d7..ef9ba32e6 100644
--- a/spec/shared/shared_log_examples.rb
+++ b/spec/shared/shared_log_examples.rb
@@ -81,6 +81,7 @@ 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
@@ -155,6 +156,7 @@ 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