Browse Source

feat: add no address found page

pull/2278/head
natdeanlewissoftwire 2 years ago
parent
commit
dd0b4bcf50
  1. 26
      app/models/form/lettings/pages/no_address_found.rb
  2. 4
      app/models/form/lettings/questions/address_selection.rb
  3. 9
      app/models/form/lettings/questions/no_address_found.rb
  4. 1
      app/models/form/lettings/subsections/property_information.rb
  5. 1
      app/services/address_client.rb
  6. 10
      config/locales/en.yml
  7. 5
      db/migrate/20240306091659_add_no_address_found_check_to_lettings_logs.rb
  8. 15
      db/schema.rb
  9. 4
      spec/models/form/lettings/questions/address_selection_spec.rb

26
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

4
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

9
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

1
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),
]

1
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

10
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.

5
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

15
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"

4
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

Loading…
Cancel
Save