Browse Source

Remove 2022-only property questions and pages

pull/2694/head
Manny Dinssa 8 months ago
parent
commit
331b308818
  1. 14
      app/models/form/lettings/pages/property_postcode.rb
  2. 15
      app/models/form/lettings/questions/postcode_full.rb
  3. 17
      app/models/form/lettings/questions/postcode_known.rb
  4. 6
      app/models/form/lettings/subsections/property_information.rb
  5. 13
      app/models/form/sales/pages/postcode.rb
  6. 9
      app/models/form/sales/pages/property_local_authority.rb
  7. 22
      app/models/form/sales/questions/postcode.rb
  8. 29
      app/models/form/sales/questions/postcode_known.rb
  9. 26
      app/models/form/sales/questions/property_local_authority_known.rb
  10. 12
      app/models/form/sales/subsections/property_information.rb
  11. 30
      spec/models/form/lettings/subsections/property_information_spec.rb
  12. 29
      spec/models/form/sales/pages/postcode_spec.rb
  13. 13
      spec/models/form/sales/pages/property_local_authority_spec.rb
  14. 47
      spec/models/form/sales/questions/postcode_known_spec.rb
  15. 46
      spec/models/form/sales/questions/postcode_spec.rb
  16. 24
      spec/models/form/sales/subsections/property_information_spec.rb

14
app/models/form/lettings/pages/property_postcode.rb

@ -1,14 +0,0 @@
class Form::Lettings::Pages::PropertyPostcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
@depends_on = [{ "is_general_needs?" => true }]
end
def questions
@questions ||= [
Form::Lettings::Questions::PostcodeKnown.new(nil, nil, self),
Form::Lettings::Questions::PostcodeFull.new(nil, nil, self),
]
end
end

15
app/models/form/lettings/questions/postcode_full.rb

@ -1,15 +0,0 @@
class Form::Lettings::Questions::PostcodeFull < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@check_answer_label = "Postcode"
@header = "What is the property’s postcode?"
@type = "text"
@width = 5
@inferred_check_answers_value = [{ "condition" => { "postcode_known" => 0 }, "value" => "Not known" }]
@check_answers_card_number = 0
@hint_text = ""
@inferred_answers = { "la" => { "is_la_inferred" => true } }
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
end

17
app/models/form/lettings/questions/postcode_known.rb

@ -1,17 +0,0 @@
class Form::Lettings::Questions::PostcodeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_known"
@check_answer_label = "Do you know the property postcode?"
@header = "Do you know the property’s postcode?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@conditional_for = { "postcode_full" => [1] }
@hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] }
end
ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze
end

6
app/models/form/lettings/subsections/property_information.rb

@ -40,16 +40,12 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection
Form::Lettings::Pages::UprnSelection.new(nil, nil, self), Form::Lettings::Pages::UprnSelection.new(nil, nil, self),
Form::Lettings::Pages::AddressFallback.new(nil, nil, self), Form::Lettings::Pages::AddressFallback.new(nil, nil, self),
] ]
elsif form.start_date.year == 2023 else
[ [
Form::Lettings::Pages::Uprn.new(nil, nil, self), Form::Lettings::Pages::Uprn.new(nil, nil, self),
Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self), Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self),
Form::Lettings::Pages::Address.new(nil, nil, self), Form::Lettings::Pages::Address.new(nil, nil, self),
] ]
else
[
Form::Lettings::Pages::PropertyPostcode.new(nil, nil, self),
]
end end
end end

13
app/models/form/sales/pages/postcode.rb

@ -1,13 +0,0 @@
class Form::Sales::Pages::Postcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
end
def questions
@questions ||= [
Form::Sales::Questions::PostcodeKnown.new(nil, nil, self),
Form::Sales::Questions::Postcode.new(nil, nil, self),
]
end
end

9
app/models/form/sales/pages/property_local_authority.rb

@ -10,14 +10,7 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
la_known_question,
Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self), Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self),
].compact ]
end
def la_known_question #TODO: Pre 2023, could be removed? Only used here.
if form.start_date.year < 2023
Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self)
end
end end
end end

22
app/models/form/sales/questions/postcode.rb

@ -1,22 +0,0 @@
class Form::Sales::Questions::Postcode < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@check_answer_label = "Property’s postcode"
@header = "Postcode"
@type = "text"
@width = 5
@inferred_check_answers_value = [{
"condition" => {
"pcodenk" => 1,
},
"value" => "Not known",
}]
@inferred_answers = {
"la" => {
"is_la_inferred" => true,
},
}
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
end

29
app/models/form/sales/questions/postcode_known.rb

@ -1,29 +0,0 @@
class Form::Sales::Questions::PostcodeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pcodenk"
@check_answer_label = "Property’s postcode"
@header = "Do you know the property’s postcode?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {
"postcode_full" => [0],
}
@hidden_in_check_answers = {
"depends_on" => [
{
"pcodenk" => 0,
},
{
"pcodenk" => 1,
},
],
}
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
ANSWER_OPTIONS = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}.freeze
end

26
app/models/form/sales/questions/property_local_authority_known.rb

@ -1,26 +0,0 @@
class Form::Sales::Questions::PropertyLocalAuthorityKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "la_known"
@check_answer_label = "Local authority known"
@header = "Do you know the property’s local authority?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = { "la" => [1] }
@hidden_in_check_answers = {
"depends_on" => [
{
"la_known" => 1,
},
],
}
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 16, 2024 => 17 }.freeze
end

12
app/models/form/sales/subsections/property_information.rb

@ -16,7 +16,6 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self), Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
(uprn_questions if form.start_date.year == 2023), (uprn_questions if form.start_date.year == 2023),
(postcode_and_la_questions if form.start_date.year < 2023), #TODO: Pre 2023, could be removed?
Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self), Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
].flatten.compact ].flatten.compact
end end
@ -49,15 +48,4 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
] ]
end end
end end
def postcode_and_la_questions #TODO: Pre 2023, could be removed?
[
Form::Sales::Pages::Postcode.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self),
]
end
end end

30
spec/models/form/lettings/subsections/property_information_spec.rb

@ -17,36 +17,6 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(false) allow(form).to receive(:start_year_after_2024?).and_return(false)
end end
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct pages" do
expect(property_information.pages.compact.map(&:id)).to eq(
%w[
property_postcode
property_local_authority
local_authority_min_rent_value_check
local_authority_max_rent_value_check
first_time_property_let_as_social_housing
property_let_type
property_vacancy_reason_not_first_let
property_vacancy_reason_first_let
property_number_of_times_relet
property_unit_type
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
beds_min_rent_value_check
beds_max_rent_value_check
void_date
void_date_value_check
property_major_repairs
property_major_repairs_value_check
],
)
end
end
context "when 2023" do context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) } let(:start_date) { Time.utc(2023, 2, 8) }

29
spec/models/form/sales/pages/postcode_spec.rb

@ -1,29 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Postcode, 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[pcodenk postcode_full])
end
it "has the correct id" do
expect(page.id).to eq("property_postcode")
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 be_nil
end
end

13
spec/models/form/sales/pages/property_local_authority_spec.rb

@ -18,19 +18,6 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
end end
describe "has correct questions" do describe "has correct questions" do
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(
%w[
la_known
la
],
)
end
end
context "when 2023" do context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) } let(:start_date) { Time.utc(2023, 2, 8) }

47
spec/models/form/sales/questions/postcode_known_spec.rb

@ -1,47 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PostcodeKnown, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("pcodenk")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"postcode_full" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{ "pcodenk" => 0 },
{ "pcodenk" => 1 },
],
})
end
end

46
spec/models/form/sales/questions/postcode_spec.rb

@ -1,46 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Postcode, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("postcode_full")
end
it "has the correct type" do
expect(question.type).to eq("text")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct width" do
expect(question.width).to eq(5)
end
it "has the correct inferred_answers" do
expect(question.inferred_answers).to eq({
"la" => {
"is_la_inferred" => true,
},
})
end
it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => {
"pcodenk" => 1,
},
"value" => "Not known",
}])
end
end

24
spec/models/form/sales/subsections/property_information_spec.rb

@ -17,30 +17,6 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(false) allow(form).to receive(:start_year_after_2024?).and_return(false)
end end
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct pages" do
expect(property_information.pages.compact.map(&:id)).to eq(
%w[
property_number_of_bedrooms
about_price_bedrooms_value_check
property_unit_type
monthly_charges_property_type_value_check
percentage_discount_proptype_value_check
property_building_type
property_postcode
property_local_authority
local_authority_buyer_1_income_max_value_check
local_authority_buyer_2_income_max_value_check
local_authority_combined_income_max_value_check
about_price_la_value_check
property_wheelchair_accessible
],
)
end
end
context "when 2023" do context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) } let(:start_date) { Time.utc(2023, 2, 8) }

Loading…
Cancel
Save