From d0ccb01cd1ad7eb49bc077068ef5741cc672126c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 07:59:01 +0000 Subject: [PATCH 1/3] Bump rack from 3.1.11 to 3.1.12 (#2983) Bumps [rack](https://github.com/rack/rack) from 3.1.11 to 3.1.12. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/v3.1.11...v3.1.12) --- updated-dependencies: - dependency-name: rack dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index bcd977d68..3d1a3f0d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -343,7 +343,7 @@ GEM activesupport (>= 3.0.0) raabro (1.4.0) racc (1.8.1) - rack (3.1.11) + rack (3.1.12) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-mini-profiler (3.3.1) From 11d9705fdd1cb1fd97187e6b191fe95831246b51 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 11 Mar 2025 08:18:29 +0000 Subject: [PATCH 2/3] Update address search results (#2981) * Update address search results * Add search controller tests * Check if the query is nil when using the address-search api * Refactor --------- Co-authored-by: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> --- app/controllers/address_search_controller.rb | 6 ++- .../address_search_controller_spec.rb | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/controllers/address_search_controller.rb b/app/controllers/address_search_controller.rb index 616d5b702..74cda65c2 100644 --- a/app/controllers/address_search_controller.rb +++ b/app/controllers/address_search_controller.rb @@ -5,7 +5,9 @@ class AddressSearchController < ApplicationController def index query = params[:query] - if query.match?(/\A\d+\z/) && query.length > 5 + if query.nil? + render json: { error: "Query cannot be blank." }, status: :bad_request + elsif query.match?(/\A\d+\z/) && query.length > 5 # Query is all numbers and greater than 5 digits, assume it's a UPRN service = UprnClient.new(query) service.call @@ -38,7 +40,7 @@ class AddressSearchController < ApplicationController address_service.call uprn_service.call - results = ([uprn_service.result] || []) + (address_service.result || []) + results = [uprn_service.result, *address_service.result].compact if address_service.error.present? && uprn_service.error.present? render json: { error: "Address and UPRN are not recognised." }, status: :not_found diff --git a/spec/requests/address_search_controller_spec.rb b/spec/requests/address_search_controller_spec.rb index 5c2acd11a..7c8523abe 100644 --- a/spec/requests/address_search_controller_spec.rb +++ b/spec/requests/address_search_controller_spec.rb @@ -144,5 +144,45 @@ RSpec.describe AddressSearchController, type: :request do expect(sales_log.la).to eq(nil) end end + + context "when searching by address and UPRN" do + let(:sales_log) { create(:sales_log, :completed, manual_address_entry_selected: false, assigned_to: user) } + + context "and theres no uprn returned" do + before do + body = { results: [{ DPA: { "ADDRESS": "1, Test Street", "UPRN": "123" } }] }.to_json + uprn_body = { results: [{ DPA: nil }] }.to_json + WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?key=OS_DATA_KEY&maxresults=10&minmatch=0.2&query=100") + .to_return(status: 200, body:, headers: {}) + WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key=OS_DATA_KEY&uprn=100") + .to_return(status: 200, body: uprn_body, headers: {}) + end + + it "returns the address results" do + get "/address-search?query=100" + + expect(response).to have_http_status(:ok) + expect(response.body).to eq([{ text: "1, Test Street", value: "123" }].to_json) + end + end + + context "and theres no address returned" do + before do + body = { results: [{ DPA: nil }] }.to_json + uprn_body = { results: [{ DPA: { "ADDRESS": "2, Test Street", UPRN: "321" } }] }.to_json + WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?key=OS_DATA_KEY&maxresults=10&minmatch=0.2&query=100") + .to_return(status: 200, body:, headers: {}) + WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?dataset=DPA,LPI&key=OS_DATA_KEY&uprn=100") + .to_return(status: 200, body: uprn_body, headers: {}) + end + + it "returns the address results" do + get "/address-search?query=100" + + expect(response).to have_http_status(:ok) + expect(response.body).to eq([{ text: "2, Test Street", value: "321" }].to_json) + end + end + end end end From 4d5f81490f773b31e0caa39ce0f9419b79190afe Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 11 Mar 2025 09:28:28 +0000 Subject: [PATCH 3/3] CLDC-3916: Lettings always show property information section 25/26 onwards (#2980) * Show lettings property information section always in 2025 * Add test --- .../lettings/subsections/property_information.rb | 2 ++ .../subsections/property_information_spec.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 475ff0a8c..3b827bf48 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -56,6 +56,8 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection end def displayed_in_tasklist?(log) + return true if form.start_year_2025_or_later? + !(log.is_supported_housing? && log.is_renewal?) end end diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb index 2630c83d4..ed0add494 100644 --- a/spec/models/form/lettings/subsections/property_information_spec.rb +++ b/spec/models/form/lettings/subsections/property_information_spec.rb @@ -84,6 +84,14 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do ], ) end + + context "when it is supported housing and a renewal" do + let(:log) { FactoryBot.build(:lettings_log, needstype: 2, renewal: 1) } + + it "is not displayed in tasklist" do + expect(property_information.displayed_in_tasklist?(log)).to eq(false) + end + end end context "when 2025" do @@ -118,6 +126,14 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do ], ) end + + context "when it is supported housing and a renewal" do + let(:log) { FactoryBot.build(:lettings_log, needstype: 2, renewal: 1) } + + it "is displayed in tasklist" do + expect(property_information.displayed_in_tasklist?(log)).to eq(true) + end + end end end