From a08f6a6ca898d2e5811d8df7c2305204cd5948c6 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:40:05 +0100 Subject: [PATCH 1/6] Allow discarding users for merged orgs (#2518) --- app/models/user.rb | 3 ++- spec/models/organisation_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 27187529a..d25faaa53 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -264,7 +264,8 @@ class User < ApplicationRecord end def discard! - update!(discarded_at: Time.zone.now) + self.discarded_at = Time.zone.now + save!(validate: false) end protected diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index d00f79039..3964923f0 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -298,4 +298,25 @@ RSpec.describe Organisation, type: :model do expect(organisation.status).to be(:active) end end + + describe "discard" do + let(:organisation) { create(:organisation) } + let!(:user) { create(:user, organisation:) } + let!(:scheme) { create(:scheme, owning_organisation: organisation) } + + context "when merged organisation is discarded" do + before do + organisation.merge_date = Time.zone.yesterday + organisation.absorbing_organisation_id = create(:organisation).id + organisation.save! + end + + it "discards all of the organisation resources" do + organisation.discard! + expect(organisation.status).to eq(:deleted) + expect(user.reload.status).to eq(:deleted) + expect(scheme.reload.status).to eq(:deleted) + end + end + end end From 6273a076cb67cb5881db64594e0014de6d2da1da Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:50:29 +0100 Subject: [PATCH 2/6] CLDC-3414&5 Close 2023/24 - No new/No editing of entries (#2520) * Close 2023/24 --- app/models/form.rb | 2 ++ .../forms/prepare_your_file_2024.html.erb | 2 +- app/views/layouts/_collection_resources.html.erb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/form.rb b/app/models/form.rb index 755121473..4336376e6 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -11,6 +11,8 @@ class Form }, 2023 => { submission_deadline: Time.zone.local(2024, 6, 7), + new_logs_end_date: Time.zone.local(2024, 7, 22), + edit_end_date: Time.zone.local(2024, 7, 22), }, 2024 => { submission_deadline: Time.zone.local(2025, 6, 6), diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb index 6413d70cb..45ce4b385 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb @@ -26,7 +26,7 @@
  • If you have reordered the headers, keep the headers in the file.
  • - <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023/24 data.") %> + <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2024/25 data.") %>

    Save your file

    diff --git a/app/views/layouts/_collection_resources.html.erb b/app/views/layouts/_collection_resources.html.erb index acdc5cb88..48976088a 100644 --- a/app/views/layouts/_collection_resources.html.erb +++ b/app/views/layouts/_collection_resources.html.erb @@ -6,7 +6,9 @@

    Collection resources

    <% end %>

    Use the 2024 to 2025 forms for lettings that start and sales that complete between 1 April 2024 and 31 March 2025.

    -

    Use the 2023 to 2024 forms for lettings that start and sales that complete between 1 April 2023 and 31 March 2024.

    +<% if FormHandler.instance.lettings_form_for_start_year(2023) && FormHandler.instance.lettings_form_for_start_year(2023).edit_end_date > Time.zone.today %> +

    Use the 2023 to 2024 forms for lettings that start and sales that complete between 1 April 2023 and 31 March 2024.

    +<% end %>
    <%= govuk_tabs(title: "Collection resources", classes: %w[app-tab__small-headers]) do |c| %> <% if FormHandler.instance.lettings_form_for_start_year(2024) && FormHandler.instance.lettings_form_for_start_year(2024).edit_end_date > Time.zone.today %> From 6c03a6d203fed5c4b428b347b387953e507bf4e1 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 22 Jul 2024 08:12:37 +0100 Subject: [PATCH 3/6] CLDC-3562 Add scheme ID to the hint text (#2519) * Add scheme ID to the hint text * Fix flaky tests --- app/helpers/question_view_helper.rb | 2 +- .../form/accessible_autocomplete_spec.rb | 30 +++++++++++++++++++ spec/models/sales_log_spec.rb | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/helpers/question_view_helper.rb b/app/helpers/question_view_helper.rb index 0c67a9f89..01745b66f 100644 --- a/app/helpers/question_view_helper.rb +++ b/app/helpers/question_view_helper.rb @@ -34,7 +34,7 @@ module QuestionViewHelper def answer_option_hint(resource) return unless resource.instance_of?(Scheme) - [resource.primary_client_group, resource.secondary_client_group].compact.join(", ") + "(S#{resource.id})" + [resource.primary_client_group, resource.secondary_client_group].compact.join(", ") end def select_option_name(value) diff --git a/spec/features/form/accessible_autocomplete_spec.rb b/spec/features/form/accessible_autocomplete_spec.rb index cd9780df1..0eb32c4a5 100644 --- a/spec/features/form/accessible_autocomplete_spec.rb +++ b/spec/features/form/accessible_autocomplete_spec.rb @@ -55,6 +55,36 @@ RSpec.describe "Accessible Autocomplete" do it "displays the placeholder text", js: true do expect(find("#lettings-log-prevloc-field")["placeholder"]).to eq("Start typing to search") end + + context "and multiple schemes with same names", js: true do + let(:lettings_log) { FactoryBot.create(:lettings_log, :sh, assigned_to: user) } + let!(:schemes) { FactoryBot.create_list(:scheme, 2, owning_organisation_id: user.organisation_id, service_name: "Scheme", primary_client_group: "O", secondary_client_group: "O") } + + before do + schemes.each do |scheme| + FactoryBot.create(:location, scheme:) + end + + visit("/lettings-logs/#{lettings_log.id}/scheme") + end + + it "allows selecting any scheme" do + find("#lettings-log-scheme-id-field").click.native.send_keys("s", "c", "h", :enter) + expect(find("#lettings-log-scheme-id-field").value).to match(/Scheme/) + click_button("Save and continue") + first_selected_scheme_id = lettings_log.reload.scheme_id + expect(schemes.map(&:id)).to include(first_selected_scheme_id) + + visit("/lettings-logs/#{lettings_log.id}/scheme") + find("#lettings-log-scheme-id-field").click.native.send_keys("s", "c", "h", :down, :enter) + expect(find("#lettings-log-scheme-id-field").value).to match(/Scheme/) + click_button("Save and continue") + + second_selected_scheme_id = lettings_log.reload.scheme_id + expect(schemes.map(&:id)).to include(lettings_log.reload.scheme_id) + expect(first_selected_scheme_id).not_to eq(second_selected_scheme_id) + end + end end context "when searching schemes" do diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 989a8e334..f0440f530 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -173,7 +173,7 @@ RSpec.describe SalesLog, type: :model do end describe "#search_by" do - let!(:sales_log_to_search) { create(:sales_log, :completed) } + let!(:sales_log_to_search) { create(:sales_log, :completed, id: 193_285) } it "allows searching using ID" do result = described_class.search_by(sales_log_to_search.id.to_s) From a92c401a4d33860a0f5273902205ca682493ef98 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:40:59 +0100 Subject: [PATCH 4/6] Make sure archived filters are removed after crossover (#2522) * Make sure archived filters are removed after crossover * Fix feature tests --- app/helpers/filters_helper.rb | 9 ++++++-- spec/features/organisation_spec.rb | 2 ++ spec/helpers/filters_helper_spec.rb | 32 +++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index f60946c74..38c15b82b 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -95,11 +95,16 @@ module FiltersHelper end def collection_year_options - { + years = { current_collection_start_year.to_s => year_combo(current_collection_start_year), previous_collection_start_year.to_s => year_combo(previous_collection_start_year), - archived_collection_start_year.to_s => year_combo(archived_collection_start_year), } + + if FormHandler.instance.in_crossover_period? + return years.merge({ archived_collection_start_year.to_s => year_combo(archived_collection_start_year) }) + end + + years end def collection_year_radio_options diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index fde7e7b6d..65f787c2a 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -131,6 +131,7 @@ RSpec.describe "User Features" do let(:number_of_lettings_logs) { LettingsLog.count } before do + allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(true) visit("/organisations/#{org_id}/lettings-logs") end @@ -220,6 +221,7 @@ RSpec.describe "User Features" do let(:number_of_sales_logs) { SalesLog.count } before do + allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(true) FactoryBot.create_list(:sales_log, 4, owning_organisation_id: organisation.id) visit("/organisations/#{org_id}/sales-logs") end diff --git a/spec/helpers/filters_helper_spec.rb b/spec/helpers/filters_helper_spec.rb index fb7bda18e..f04157521 100644 --- a/spec/helpers/filters_helper_spec.rb +++ b/spec/helpers/filters_helper_spec.rb @@ -245,12 +245,32 @@ RSpec.describe FiltersHelper do allow(Time).to receive(:now).and_return(Time.zone.local(2023, 5, 1)) end - it "has the correct options" do - expect(collection_year_options).to eq( - { - "2023" => "2023/24", "2022" => "2022/23", "2021" => "2021/22" - }, - ) + context "and in crossover period" do + before do + allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(true) + end + + it "has the correct options" do + expect(collection_year_options).to eq( + { + "2023" => "2023/24", "2022" => "2022/23", "2021" => "2021/22" + }, + ) + end + end + + context "and not in crossover period" do + before do + allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(false) + end + + it "has the correct options" do + expect(collection_year_options).to eq( + { + "2023" => "2023/24", "2022" => "2022/23" + }, + ) + end end end From fb89b47b6f283b996db8aff622e1ea6ecfadd9ad Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:07:58 +0100 Subject: [PATCH 5/6] CLDC-3520 order scheme locations (#2499) * List in alphabetical order using second line of address (.i.e. hint/name) --- .gitignore | 3 +- app/helpers/question_view_helper.rb | 9 ++- .../lettings_log_variables.rb | 7 -- app/models/form/lettings/pages/location.rb | 1 + .../form/lettings/pages/location_search.rb | 20 ++++++ .../form/lettings/questions/location_id.rb | 5 ++ .../lettings/questions/location_id_search.rb | 64 +++++++++++++++++++ app/models/form/lettings/subsections/setup.rb | 1 + app/models/form/question.rb | 2 + app/models/lettings_log.rb | 14 ++++ spec/helpers/question_view_helper_spec.rb | 54 +++++++++++++++- .../lettings/pages/location_search_spec.rb | 19 ++++++ .../form/lettings/pages/location_spec.rb | 1 + .../lettings/questions/location_id_spec.rb | 27 ++++++++ .../form/lettings/subsections/setup_spec.rb | 2 + 15 files changed, 218 insertions(+), 11 deletions(-) create mode 100644 app/models/form/lettings/pages/location_search.rb create mode 100644 app/models/form/lettings/questions/location_id_search.rb create mode 100644 spec/models/form/lettings/pages/location_search_spec.rb diff --git a/.gitignore b/.gitignore index b2b589114..ddda1de2c 100644 --- a/.gitignore +++ b/.gitignore @@ -53,8 +53,9 @@ yarn-debug.log* .DS_Store .generators .rakeTasks +.vscode /app/assets/builds/* !/app/assets/builds/.keep -spec/examples.txt +spec/examples.txt \ No newline at end of file diff --git a/app/helpers/question_view_helper.rb b/app/helpers/question_view_helper.rb index 01745b66f..acb4fa959 100644 --- a/app/helpers/question_view_helper.rb +++ b/app/helpers/question_view_helper.rb @@ -32,14 +32,19 @@ module QuestionViewHelper end def answer_option_hint(resource) - return unless resource.instance_of?(Scheme) + return unless resource.instance_of?(Scheme) || resource.instance_of?(Location) - "(S#{resource.id})" + [resource.primary_client_group, resource.secondary_client_group].compact.join(", ") + if resource.instance_of?(Scheme) + "(S#{resource.id}) " + [resource.primary_client_group, resource.secondary_client_group].compact.join(", ") + elsif resource.instance_of?(Location) + resource.name + end end def select_option_name(value) return value.service_name if value.respond_to?(:service_name) return value["name"] if value.is_a?(Hash) && value["name"].present? + return value["postcode"] if value.is_a?(Location) end private diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index 91e645c47..e50161188 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -28,13 +28,6 @@ module DerivedVariables::LettingsLogVariables 5 => 6, }.freeze - def scheme_has_multiple_locations? - return false unless scheme - - scheme_locations_count = scheme.locations.active_in_2_weeks.size - scheme_locations_count > 1 - end - def set_derived_fields! clear_inapplicable_derived_values! set_encoded_derived_values!(DEPENDENCIES) diff --git a/app/models/form/lettings/pages/location.rb b/app/models/form/lettings/pages/location.rb index 2c040661a..ba357dc1b 100644 --- a/app/models/form/lettings/pages/location.rb +++ b/app/models/form/lettings/pages/location.rb @@ -5,6 +5,7 @@ class Form::Lettings::Pages::Location < ::Form::Page { "needstype" => 2, "scheme_has_multiple_locations?" => true, + "scheme_has_large_number_of_locations?" => false, }, ] @header = "Location" diff --git a/app/models/form/lettings/pages/location_search.rb b/app/models/form/lettings/pages/location_search.rb new file mode 100644 index 000000000..f27fae281 --- /dev/null +++ b/app/models/form/lettings/pages/location_search.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Pages::LocationSearch < ::Form::Page + def initialize(_id, hsh, subsection) + super("location_search", hsh, subsection) + @depends_on = [ + { + "needstype" => 2, + "scheme_has_multiple_locations?" => true, + "scheme_has_large_number_of_locations?" => true, + }, + ] + @header = "Location" + @next_unresolved_page_id = :check_answers + end + + def questions + @questions ||= [ + Form::Lettings::Questions::LocationIdSearch.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index d79bcab76..59101592f 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -31,6 +31,11 @@ class Form::Lettings::Questions::LocationId < ::Form::Question scheme_location_ids = lettings_log.scheme.locations.visible.confirmed.pluck(:id) answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) } + .sort_by { |_, v| + name = v["hint"].match(/[a-zA-Z].*/).to_s + number = v["hint"].match(/\d+/).to_s.to_i + [name, number] + }.to_h end def hidden_in_check_answers?(lettings_log, _current_user = nil) diff --git a/app/models/form/lettings/questions/location_id_search.rb b/app/models/form/lettings/questions/location_id_search.rb new file mode 100644 index 000000000..d085572e4 --- /dev/null +++ b/app/models/form/lettings/questions/location_id_search.rb @@ -0,0 +1,64 @@ +class Form::Lettings::Questions::LocationIdSearch < ::Form::Question + def initialize(id, hsh, page) + super + @id = "location_id" + @check_answer_label = "Location" + @header = header_text + @hint_text = '
    This scheme has 20 or more locations.
    Enter postcode or address.' + @type = "select" + @answer_options = answer_options + @inferred_answers = { + "location.name": { + "needstype": 2, + }, + } + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? + @disable_clearing_if_not_routed_or_dynamic_answer_options = true + @top_guidance_partial = "finding_location" + end + + def answer_options + answer_opts = {} + return answer_opts unless ActiveRecord::Base.connected? + + Location.visible.started_in_2_weeks.select(:id, :postcode, :name).each_with_object(answer_opts) do |location, hsh| + hsh[location.id.to_s] = location + hsh + end + end + + def displayed_answer_options(lettings_log, _user = nil) + return {} unless lettings_log.scheme + + scheme_location_ids = lettings_log.scheme.locations.visible.confirmed.pluck(:id) + answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) }.to_h + end + + def hidden_in_check_answers?(lettings_log, _current_user = nil) + !supported_housing_selected?(lettings_log) + end + + def get_extra_check_answer_value(lettings_log) + lettings_log.form.get_question("la", nil).label_from_value(lettings_log.la) + end + +private + + def supported_housing_selected?(lettings_log) + lettings_log.needstype == 2 + end + + def selected_answer_option_is_derived?(_lettings_log) + false + end + + def header_text + if form.start_date && form.start_date.year >= 2023 + "Which location is this letting for?" + else + "Which location is this log for?" + end + end + + QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze +end diff --git a/app/models/form/lettings/subsections/setup.rb b/app/models/form/lettings/subsections/setup.rb index 85af7d2c4..1970149ed 100644 --- a/app/models/form/lettings/subsections/setup.rb +++ b/app/models/form/lettings/subsections/setup.rb @@ -14,6 +14,7 @@ class Form::Lettings::Subsections::Setup < ::Form::Subsection Form::Lettings::Pages::NeedsType.new(nil, nil, self), Form::Lettings::Pages::Scheme.new(nil, nil, self), Form::Lettings::Pages::Location.new(nil, nil, self), + Form::Lettings::Pages::LocationSearch.new(nil, nil, self), Form::Lettings::Pages::Renewal.new(nil, nil, self), Form::Lettings::Pages::TenancyStartDate.new(nil, nil, self), Form::Lettings::Pages::RentType.new(nil, nil, self), diff --git a/app/models/form/question.rb b/app/models/form/question.rb index aa019c1c6..a692574dd 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -160,6 +160,8 @@ class Form::Question when "select" if answer_options[value.to_s].respond_to?(:service_name) answer_options[value.to_s].service_name + elsif answer_options[value.to_s].is_a?(Location) + answer_options[value.to_s].postcode else answer_options[value.to_s] end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 60ac5e166..eab05c997 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -706,6 +706,20 @@ class LettingsLog < Log self.la = inferred_la if inferred_la.present? end + def scheme_has_multiple_locations? + return false unless scheme + + scheme_locations_count ||= scheme.locations.active_in_2_weeks.size + scheme_locations_count > 1 + end + + def scheme_has_large_number_of_locations? + return false unless scheme + + scheme_locations_count ||= scheme.locations.active_in_2_weeks.size + scheme_locations_count > 19 + end + private def reset_invalid_unresolved_log_fields! diff --git a/spec/helpers/question_view_helper_spec.rb b/spec/helpers/question_view_helper_spec.rb index 2f7e82285..af7282cb3 100644 --- a/spec/helpers/question_view_helper_spec.rb +++ b/spec/helpers/question_view_helper_spec.rb @@ -32,7 +32,7 @@ RSpec.describe QuestionViewHelper do end end - context "when viewig a question without a caption" do + context "when viewing a question without a caption" do let(:caption_text) { nil } it "returns nil" do @@ -114,4 +114,56 @@ RSpec.describe QuestionViewHelper do end end end + + describe "select_option_name" do + context "when value is a location" do + let(:value) { build(:location) } + + it "returns the location's postcode" do + expect(select_option_name(value)).to eq(value.postcode) + end + end + + context "when value is a hash with a name key" do + let(:value) { { "name" => "example name" } } + + it "returns the value of the name key" do + expect(select_option_name(value)).to eq(value["name"]) + end + end + + context "when value responds to service_name" do + let(:value) { build(:scheme) } + + it "returns the value of the service_name method" do + expect(select_option_name(value)).to eq(value.service_name) + end + end + end + + describe "answer_option_hint" do + context "when not a scheme or location" do + let(:resource) { { "value" => "not a scheme or location" } } + + it "returns nil" do + expect(answer_option_hint(resource)).to be_nil + end + end + + context "when resource is a scheme" do + let(:resource) { build(:scheme, primary_client_group: "O", secondary_client_group: "E", id: 2_736_276) } + + it "returns the primary and secondary client groups" do + expect(answer_option_hint(resource)).to eq("(S2736276) Homeless families with support needs, People with mental health problems") + end + end + + context "when resource is a location" do + let(:resource) { build(:location) } + + it "returns the location's name" do + expect(answer_option_hint(resource)).to eq(resource.name) + end + end + end end diff --git a/spec/models/form/lettings/pages/location_search_spec.rb b/spec/models/form/lettings/pages/location_search_spec.rb new file mode 100644 index 000000000..c4362e782 --- /dev/null +++ b/spec/models/form/lettings/pages/location_search_spec.rb @@ -0,0 +1,19 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::LocationSearch, 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) } + + it "has the correct depends_on" do + expect(page.depends_on).to eq([ + { + "needstype" => 2, + "scheme_has_multiple_locations?" => true, + "scheme_has_large_number_of_locations?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/pages/location_spec.rb b/spec/models/form/lettings/pages/location_spec.rb index 10e8fdf09..6de0b59dd 100644 --- a/spec/models/form/lettings/pages/location_spec.rb +++ b/spec/models/form/lettings/pages/location_spec.rb @@ -38,6 +38,7 @@ RSpec.describe Form::Lettings::Pages::Location, type: :model do { "needstype" => 2, "scheme_has_multiple_locations?" => true, + "scheme_has_large_number_of_locations?" => false, }, ]) end diff --git a/spec/models/form/lettings/questions/location_id_spec.rb b/spec/models/form/lettings/questions/location_id_spec.rb index 103ca3404..ac3cfb8b5 100644 --- a/spec/models/form/lettings/questions/location_id_spec.rb +++ b/spec/models/form/lettings/questions/location_id_spec.rb @@ -147,6 +147,33 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do expect(question.displayed_answer_options(lettings_log).count).to eq(1) end end + + context "and some locations start with numbers" do + before do + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 5), name: "2 Abe Road") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 6), name: "1 Abe Road") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 7), name: "1 Lake Lane") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 8), name: "3 Abe Road") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 9), name: "2 Lake Lane") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 10), name: "Smith Avenue") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 11), name: "Abacus Road") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 12), name: "Hawthorne Road") + lettings_log.update!(scheme:) + end + + it "orders the locations by name then numerically" do + expect(question.displayed_answer_options(lettings_log).values.map { |v| v["hint"] }).to eq([ + "Abacus Road", + "1 Abe Road", + "2 Abe Road", + "3 Abe Road", + "Hawthorne Road", + "1 Lake Lane", + "2 Lake Lane", + "Smith Avenue", + ]) + end + end end end diff --git a/spec/models/form/lettings/subsections/setup_spec.rb b/spec/models/form/lettings/subsections/setup_spec.rb index 824f4bf80..074f7ae5e 100644 --- a/spec/models/form/lettings/subsections/setup_spec.rb +++ b/spec/models/form/lettings/subsections/setup_spec.rb @@ -30,6 +30,7 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do needs_type scheme location + location_search renewal tenancy_start_date rent_type @@ -54,6 +55,7 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do needs_type scheme location + location_search renewal tenancy_start_date rent_type From 9d08cf9c85b9778472c7fedbe389fbefd0560539 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:23:18 +0100 Subject: [PATCH 6/6] Update rails-admin (#2521) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 40fd90036..af927c0f1 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "html5shiv": "^3.7.3", "intersection-observer": "^0.12.0", "mini-css-extract-plugin": "^2.6.0", - "rails_admin": "3.1.2", + "rails_admin": "3.1.3", "regenerator-runtime": "^0.13.9", "sass": "^1.49.9", "sass-loader": "^12.6.0", diff --git a/yarn.lock b/yarn.lock index 0cb18e71c..e59022be7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4703,10 +4703,10 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== -rails_admin@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/rails_admin/-/rails_admin-3.1.2.tgz#00d6d85b7a00c89c69b5dbf5f1f4620702626504" - integrity sha512-uIQHN27lBvlav6s5ppmOtVxKN8GIxyhHuDFc9ZbvWgFknR4zgG4/xEUGzKzQ9R34AEsfZ/t8cZbvtvgj+aXp4A== +rails_admin@3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/rails_admin/-/rails_admin-3.1.3.tgz#1da3f2214876f4ffd3a1db01452c28a8f7d4d989" + integrity sha512-79CBB2BMB3fSGPz1P8eNxCboHVlkBWBaxKxfo4QwCAFxsA3WAjfM0MeWUtGHI8Mn8XEZxCdEDz9oYlvlBpMtng== dependencies: "@babel/runtime" "^7.16.7" "@fortawesome/fontawesome-free" ">=5.15.0 <7.0.0"