Browse Source

Cldc 2445 increase offered max (#1692)

* feat: update max and add new spec

* feat: update previous years

* feat: combine identical offered questions

* feat: update tests

* feat: add test for property_number_of_times_relet
pull/1676/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
240e8a03b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/models/form/lettings/pages/property_number_of_times_relet.rb
  2. 11
      app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb
  3. 11
      app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb
  4. 2
      app/models/form/lettings/questions/offered.rb
  5. 16
      app/models/form/lettings/questions/offered_social_let.rb
  6. 3
      app/models/form/lettings/subsections/property_information.rb
  7. 4
      config/forms/2021_2022.json
  8. 4
      config/forms/2022_2023.json
  9. 36
      spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb
  10. 4
      spec/models/form/lettings/questions/offered_spec.rb
  11. 6
      spec/models/form/lettings/subsections/property_information_spec.rb
  12. 6
      spec/services/imports/lettings_logs_import_service_spec.rb

12
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

11
app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb

@ -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

11
app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb

@ -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

2
app/models/form/lettings/questions/offered.rb

@ -7,7 +7,7 @@ class Form::Lettings::Questions::Offered < ::Form::Question
@type = "numeric" @type = "numeric"
@width = 2 @width = 2
@check_answers_card_number = 0 @check_answers_card_number = 0
@max = 20 @max = 150
@min = 0 @min = 0
@hint_text = I18n.t("hints.offered") @hint_text = I18n.t("hints.offered")
@step = 1 @step = 1

16
app/models/form/lettings/questions/offered_social_let.rb

@ -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

3
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::PropertyLetType.new(nil, nil, self),
Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet.new(nil, nil, self), Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet.new(nil, nil, self),
Form::Lettings::Pages::PropertyVacancyReasonFirstLet.new(nil, nil, self), Form::Lettings::Pages::PropertyVacancyReasonFirstLet.new(nil, nil, self),
Form::Lettings::Pages::PropertyNumberOfTimesReletNotSocialLet.new(nil, nil, self), Form::Lettings::Pages::PropertyNumberOfTimesRelet.new(nil, nil, self),
Form::Lettings::Pages::PropertyNumberOfTimesReletSocialLet.new(nil, nil, self),
Form::Lettings::Pages::PropertyUnitType.new(nil, nil, self), Form::Lettings::Pages::PropertyUnitType.new(nil, nil, self),
Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self), Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self), Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self),

4
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.", "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", "type": "numeric",
"min": 0, "min": 0,
"max": 20, "max": 150,
"step": 1, "step": 1,
"width": 2 "width": 2
} }
@ -591,7 +591,7 @@
"hint_text": "If the property is being offered for let for the first time, enter 0.", "hint_text": "If the property is being offered for let for the first time, enter 0.",
"type": "numeric", "type": "numeric",
"min": 0, "min": 0,
"max": 20, "max": 150,
"step": 1, "step": 1,
"width": 2 "width": 2
} }

4
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.", "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", "type": "numeric",
"min": 0, "min": 0,
"max": 20, "max": 150,
"step": 1, "step": 1,
"width": 2 "width": 2
} }
@ -586,7 +586,7 @@
"hint_text": "If the property is being offered for let for the first time, enter 0.", "hint_text": "If the property is being offered for let for the first time, enter 0.",
"type": "numeric", "type": "numeric",
"min": 0, "min": 0,
"max": 20, "max": 150,
"step": 1, "step": 1,
"width": 2 "width": 2
} }

36
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

4
spec/models/form/lettings/questions/offered_social_let_spec.rb → spec/models/form/lettings/questions/offered_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" 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) } subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::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 it "has the correct minimum and maximum values" do
expect(question.min).to be 0 expect(question.min).to be 0
expect(question.max).to be 20 expect(question.max).to be 150
end end
it "has the correct step" do it "has the correct step" do

6
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_let_type
property_vacancy_reason_not_first_let property_vacancy_reason_not_first_let
property_vacancy_reason_first_let property_vacancy_reason_first_let
property_number_of_times_relet_not_social_let property_number_of_times_relet
property_number_of_times_relet_social_let
property_unit_type property_unit_type
property_building_type property_building_type
property_wheelchair_accessible property_wheelchair_accessible
@ -59,8 +58,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_let_type property_let_type
property_vacancy_reason_not_first_let property_vacancy_reason_not_first_let
property_vacancy_reason_first_let property_vacancy_reason_first_let
property_number_of_times_relet_not_social_let property_number_of_times_relet
property_number_of_times_relet_social_let
property_unit_type property_unit_type
property_building_type property_building_type
property_wheelchair_accessible property_wheelchair_accessible

6
spec/services/imports/lettings_logs_import_service_spec.rb

@ -456,13 +456,13 @@ RSpec.describe Imports::LettingsLogsImportService do
end end
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 before do
lettings_log_xml.at_xpath("//xmlns:Q20").content = "25" lettings_log_xml.at_xpath("//xmlns:Q20").content = "155"
end end
it "intercepts the relevant validation error" do 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) } expect { lettings_log_service.send(:create_log, lettings_log_xml) }
.not_to raise_error .not_to raise_error
end end

Loading…
Cancel
Save