diff --git a/app/models/form/lettings/pages/property_number_of_times_relet.rb b/app/models/form/lettings/pages/property_number_of_times_relet.rb new file mode 100644 index 000000000..e8ad9faae --- /dev/null +++ b/app/models/form/lettings/pages/property_number_of_times_relet.rb @@ -0,0 +1,12 @@ +class Form::Lettings::Pages::PropertyNumberOfTimesRelet < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_number_of_times_relet" + @depends_on = [{ "first_time_property_let_as_social_housing" => 0, "is_renewal?" => false }, + { "first_time_property_let_as_social_housing" => 1, "is_renewal?" => false }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Offered.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb b/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb deleted file mode 100644 index b82a4757e..000000000 --- a/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Form::Lettings::Pages::PropertyNumberOfTimesReletNotSocialLet < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "property_number_of_times_relet_not_social_let" - @depends_on = [{ "first_time_property_let_as_social_housing" => 0, "is_renewal?" => false }] - end - - def questions - @questions ||= [Form::Lettings::Questions::Offered.new(nil, nil, self)] - end -end diff --git a/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb b/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb deleted file mode 100644 index 5785a2961..000000000 --- a/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Form::Lettings::Pages::PropertyNumberOfTimesReletSocialLet < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "property_number_of_times_relet_social_let" - @depends_on = [{ "first_time_property_let_as_social_housing" => 1, "is_renewal?" => false }] - end - - def questions - @questions ||= [Form::Lettings::Questions::OfferedSocialLet.new(nil, nil, self)] - end -end diff --git a/app/models/form/lettings/questions/offered.rb b/app/models/form/lettings/questions/offered.rb index 2c9828d31..e41def301 100644 --- a/app/models/form/lettings/questions/offered.rb +++ b/app/models/form/lettings/questions/offered.rb @@ -7,7 +7,7 @@ class Form::Lettings::Questions::Offered < ::Form::Question @type = "numeric" @width = 2 @check_answers_card_number = 0 - @max = 20 + @max = 150 @min = 0 @hint_text = I18n.t("hints.offered") @step = 1 diff --git a/app/models/form/lettings/questions/offered_social_let.rb b/app/models/form/lettings/questions/offered_social_let.rb deleted file mode 100644 index dd57acbfe..000000000 --- a/app/models/form/lettings/questions/offered_social_let.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Form::Lettings::Questions::OfferedSocialLet < ::Form::Question - def initialize(id, hsh, page) - super - @id = "offered" - @check_answer_label = I18n.t("check_answer_labels.offered") - @header = I18n.t("questions.offered") - @type = "numeric" - @width = 2 - @check_answers_card_number = 0 - @max = 20 - @min = 0 - @hint_text = I18n.t("hints.offered") - @step = 1 - @question_number = 18 - end -end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 0f921d4a5..860d4ea88 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -16,8 +16,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::PropertyLetType.new(nil, nil, self), Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet.new(nil, nil, self), Form::Lettings::Pages::PropertyVacancyReasonFirstLet.new(nil, nil, self), - Form::Lettings::Pages::PropertyNumberOfTimesReletNotSocialLet.new(nil, nil, self), - Form::Lettings::Pages::PropertyNumberOfTimesReletSocialLet.new(nil, nil, self), + Form::Lettings::Pages::PropertyNumberOfTimesRelet.new(nil, nil, self), Form::Lettings::Pages::PropertyUnitType.new(nil, nil, self), Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self), Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self), diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 84065e019..75660731d 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -569,7 +569,7 @@ "hint_text": "This is after the last tenancy ended. If the property is being offered for let for the first time, enter 0.", "type": "numeric", "min": 0, - "max": 20, + "max": 150, "step": 1, "width": 2 } @@ -591,7 +591,7 @@ "hint_text": "If the property is being offered for let for the first time, enter 0.", "type": "numeric", "min": 0, - "max": 20, + "max": 150, "step": 1, "width": 2 } diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index a76e8f6ad..7e4318998 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -564,7 +564,7 @@ "hint_text": "This is after the last tenancy ended. If the property is being offered for let for the first time, enter 0.", "type": "numeric", "min": 0, - "max": 20, + "max": 150, "step": 1, "width": 2 } @@ -586,7 +586,7 @@ "hint_text": "If the property is being offered for let for the first time, enter 0.", "type": "numeric", "min": 0, - "max": 20, + "max": 150, "step": 1, "width": 2 } diff --git a/spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb b/spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb new file mode 100644 index 000000000..4612dd31a --- /dev/null +++ b/spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb @@ -0,0 +1,36 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PropertyNumberOfTimesRelet, 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 correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[offered]) + end + + it "has the correct id" do + expect(page.id).to eq("property_number_of_times_relet") + end + + it "has the correct header" do + expect(page.header).to be_nil + 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( + [{ "first_time_property_let_as_social_housing" => 0, "is_renewal?" => false }, + { "first_time_property_let_as_social_housing" => 1, "is_renewal?" => false }], + ) + end +end diff --git a/spec/models/form/lettings/questions/offered_social_let_spec.rb b/spec/models/form/lettings/questions/offered_spec.rb similarity index 91% rename from spec/models/form/lettings/questions/offered_social_let_spec.rb rename to spec/models/form/lettings/questions/offered_spec.rb index ac1930495..09d103a1b 100644 --- a/spec/models/form/lettings/questions/offered_social_let_spec.rb +++ b/spec/models/form/lettings/questions/offered_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Lettings::Questions::OfferedSocialLet, type: :model do +RSpec.describe Form::Lettings::Questions::Offered, type: :model do subject(:question) { described_class.new(nil, nil, page) } let(:page) { instance_double(Form::Page) } @@ -27,7 +27,7 @@ RSpec.describe Form::Lettings::Questions::OfferedSocialLet, type: :model do it "has the correct minimum and maximum values" do expect(question.min).to be 0 - expect(question.max).to be 20 + expect(question.max).to be 150 end it "has the correct step" do diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb index 0eac3a27a..6ba46f38a 100644 --- a/spec/models/form/lettings/subsections/property_information_spec.rb +++ b/spec/models/form/lettings/subsections/property_information_spec.rb @@ -26,8 +26,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do property_let_type property_vacancy_reason_not_first_let property_vacancy_reason_first_let - property_number_of_times_relet_not_social_let - property_number_of_times_relet_social_let + property_number_of_times_relet property_unit_type property_building_type property_wheelchair_accessible @@ -59,8 +58,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do property_let_type property_vacancy_reason_not_first_let property_vacancy_reason_first_let - property_number_of_times_relet_not_social_let - property_number_of_times_relet_social_let + property_number_of_times_relet property_unit_type property_building_type property_wheelchair_accessible diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb index d8d1ab401..00db327d5 100644 --- a/spec/services/imports/lettings_logs_import_service_spec.rb +++ b/spec/services/imports/lettings_logs_import_service_spec.rb @@ -456,13 +456,13 @@ RSpec.describe Imports::LettingsLogsImportService do end end - context "and the number the property was relet is over 20" do + context "and the number the property was relet is over 150" do before do - lettings_log_xml.at_xpath("//xmlns:Q20").content = "25" + lettings_log_xml.at_xpath("//xmlns:Q20").content = "155" end it "intercepts the relevant validation error" do - expect(logger).to receive(:warn).with(/Removing offered with error: Times previously offered since becoming available must be between 0 and 20/) + expect(logger).to receive(:warn).with(/Removing offered with error: Times previously offered since becoming available must be between 0 and 150/) expect { lettings_log_service.send(:create_log, lettings_log_xml) } .not_to raise_error end