From dd0b4bcf5057918bf03ff4ef8aa441f580b97da7 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 6 Mar 2024 09:42:17 +0000 Subject: [PATCH] feat: add no address found page --- .../form/lettings/pages/no_address_found.rb | 26 +++++++++++++++++++ .../lettings/questions/address_selection.rb | 4 +-- .../lettings/questions/no_address_found.rb | 9 +++++++ .../subsections/property_information.rb | 1 + app/services/address_client.rb | 1 + config/locales/en.yml | 10 ++++--- ...no_address_found_check_to_lettings_logs.rb | 5 ++++ db/schema.rb | 15 ++++++----- .../questions/address_selection_spec.rb | 4 +-- 9 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 app/models/form/lettings/pages/no_address_found.rb create mode 100644 app/models/form/lettings/questions/no_address_found.rb create mode 100644 db/migrate/20240306091659_add_no_address_found_check_to_lettings_logs.rb diff --git a/app/models/form/lettings/pages/no_address_found.rb b/app/models/form/lettings/pages/no_address_found.rb new file mode 100644 index 000000000..23eba8eed --- /dev/null +++ b/app/models/form/lettings/pages/no_address_found.rb @@ -0,0 +1,26 @@ +class Form::Lettings::Pages::NoAddressFound < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "no_address_found" + @type = "interruption_screen" + @title_text = { + "translation" => "soft_validations.no_address_found.title_text", + "arguments" => [], + } + @informative_text = { + "translation" => "soft_validations.no_address_found.informative_text", + "arguments" => [], + } + @depends_on = [{ "address_options_present?" => false }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::NoAddressFound.new(nil, nil, self), + ] + end + + def interruption_screen_question_ids + %w[address_line1_input] + end +end diff --git a/app/models/form/lettings/questions/address_selection.rb b/app/models/form/lettings/questions/address_selection.rb index 943dd24ac..d0fb17b8f 100644 --- a/app/models/form/lettings/questions/address_selection.rb +++ b/app/models/form/lettings/questions/address_selection.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::AddressSelection < ::Form::Question end def answer_options(log = nil, _user = nil) - answer_opts = { "-1" => { "value" => "The address is not listed, I want to enter the address manually" } } + answer_opts = { "100" => { "value" => "The address is not listed, I want to enter the address manually" } } return answer_opts unless ActiveRecord::Base.connected? return answer_opts unless log&.address_options @@ -20,7 +20,7 @@ class Form::Lettings::Questions::AddressSelection < ::Form::Question end answer_opts["divider"] = { "value" => true } - answer_opts["-1"] = { "value" => "The address is not listed, I want to enter the address manually" } + answer_opts["100"] = { "value" => "The address is not listed, I want to enter the address manually" } answer_opts end diff --git a/app/models/form/lettings/questions/no_address_found.rb b/app/models/form/lettings/questions/no_address_found.rb new file mode 100644 index 000000000..6f3008d0a --- /dev/null +++ b/app/models/form/lettings/questions/no_address_found.rb @@ -0,0 +1,9 @@ +class Form::Lettings::Questions::NoAddressFound < ::Form::Question + def initialize(id, hsh, page) + super + @id = "address_search_value_check" + @header = "No address found" + @type = "interruption_screen" + @hidden_in_check_answers = true + end +end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 4fdb9c922..c253cfcfe 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -36,6 +36,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::Uprn.new(nil, nil, self), Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self), Form::Lettings::Pages::AddressMatcher.new(nil, nil, self), + Form::Lettings::Pages::NoAddressFound.new(nil, nil, self), Form::Lettings::Pages::AddressSelection.new(nil, nil, self), Form::Lettings::Pages::AddressFallback.new(nil, nil, self), ] diff --git a/app/services/address_client.rb b/app/services/address_client.rb index 02fad05c3..2f0ded738 100644 --- a/app/services/address_client.rb +++ b/app/services/address_client.rb @@ -40,6 +40,7 @@ private query: address, key: ENV["OS_DATA_KEY"], maxresults: 10, + minmatch: 0.6, } uri.query = URI.encode_www_form(params) uri.to_s diff --git a/config/locales/en.yml b/config/locales/en.yml index 0eb20e1b7..3895d27c0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -690,7 +690,7 @@ Make sure these answers are correct." shared_ownership_deposit: title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}" old_persons_shared_ownership: - title_text: + title_text: one: "You told us the buyer is using the Older Persons Shared Ownership scheme." two: "You told us the buyers are using the Older Persons Shared Ownership scheme." hint_text: "At least one buyer must be aged 65 years and over to use this scheme." @@ -717,12 +717,12 @@ Make sure these answers are correct." title_text: "You told us that the percentage discount is %{discount}." hint_text: "This is higher than we would expect." savings: - title_text: + title_text: one: "You told us the buyer’s savings were %{savings}." two: "You told us the buyers’ savings were %{savings}." hint_text: "This is higher than we would expect." deposit: - title_text: + title_text: one: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." two: "You told us the buyers’ deposit was %{deposit} and their savings were %{savings}." hint_text: "The deposit amount is higher than we would expect for the amount of savings they have." @@ -754,7 +754,9 @@ Make sure these answers are correct." informative_text: "The reason you have entered looks very similar to one of the existing response categories. Please check the categories and select the appropriate one. If the existing categories are not suitable, please confirm here to move onto the next question." - + no_address_found: + title_text: "No address found" + informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." devise: email: updated: An email has been sent to %{email} to confirm this change. diff --git a/db/migrate/20240306091659_add_no_address_found_check_to_lettings_logs.rb b/db/migrate/20240306091659_add_no_address_found_check_to_lettings_logs.rb new file mode 100644 index 000000000..5d23a1657 --- /dev/null +++ b/db/migrate/20240306091659_add_no_address_found_check_to_lettings_logs.rb @@ -0,0 +1,5 @@ +class AddNoAddressFoundCheckToLettingsLogs < ActiveRecord::Migration[7.0] + def change + add_column :lettings_logs, :address_search_value_check, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index b107b985e..4c371ef59 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.0].define(version: 2024_03_04_115940) do +ActiveRecord::Schema[7.0].define(version: 2024_03_06_091659) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -193,14 +193,14 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_04_115940) do t.integer "hb" t.integer "hbrentshortfall" t.integer "property_relet" - t.datetime "mrcdate" + t.datetime "mrcdate", precision: nil t.integer "incref" - t.datetime "startdate" + t.datetime "startdate", precision: nil t.integer "armedforces" t.integer "first_time_property_let_as_social_housing" t.integer "unitletas" t.integer "builtype" - t.datetime "voiddate" + t.datetime "voiddate", precision: nil t.bigint "owning_organisation_id" t.bigint "managing_organisation_id" t.integer "renttype" @@ -304,13 +304,14 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_04_115940) do t.integer "scharge_value_check" t.integer "pscharge_value_check" t.integer "duplicate_set_id" + t.integer "accessible_register" t.integer "nationality_all" t.integer "nationality_all_group" t.integer "reasonother_value_check" - t.integer "accessible_register" t.integer "address_selection" t.string "address_line1_input" t.string "postcode_full_input" + t.integer "address_search_value_check" 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" t.index ["location_id"], name: "index_lettings_logs_on_location_id" @@ -718,8 +719,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_04_115940) do t.string "name" t.bigint "organisation_id" t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" + t.datetime "current_sign_in_at", precision: nil + t.datetime "last_sign_in_at", precision: nil t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.integer "role" diff --git a/spec/models/form/lettings/questions/address_selection_spec.rb b/spec/models/form/lettings/questions/address_selection_spec.rb index 6669f5c46..bb3941d8c 100644 --- a/spec/models/form/lettings/questions/address_selection_spec.rb +++ b/spec/models/form/lettings/questions/address_selection_spec.rb @@ -58,14 +58,14 @@ RSpec.describe Form::Lettings::Questions::AddressSelection, type: :model do stub_request(:get, /api.os.uk/) .to_return(status: 200, body: "", headers: {}) - expect(question.answer_options(log)).to eq({ "-1" => { "value" => "The address is not listed, I want to enter the address manually" }, "0" => { "value" => "full address" }, "divider" => { "value" => true } }) + expect(question.answer_options(log)).to eq({ "100" => { "value" => "The address is not listed, I want to enter the address manually" }, "0" => { "value" => "full address" }, "divider" => { "value" => true } }) end it "has the correct displayed answer options" do stub_request(:get, /api.os.uk/) .to_return(status: 200, body: "", headers: {}) - expect(question.displayed_answer_options(log)).to eq({ "-1" => { "value" => "The address is not listed, I want to enter the address manually" }, "0" => { "value" => "full address" }, "divider" => { "value" => true } }) + expect(question.displayed_answer_options(log)).to eq({ "100" => { "value" => "The address is not listed, I want to enter the address manually" }, "0" => { "value" => "full address" }, "divider" => { "value" => true } }) end it "has the correct inferred check answers value" do