From 067de660af1683bbe522a25cb6a87bc875430cfe Mon Sep 17 00:00:00 2001 From: Ted-U <92022120+Ted-U@users.noreply.github.com> Date: Thu, 22 Sep 2022 11:35:43 +0100 Subject: [PATCH] move beds question to property section --- .../property/sections/property_information.rb | 10 ++++++++++ .../property/subsections/property_information.rb | 15 +++++++++++++++ app/models/form_handler.rb | 2 +- .../pages/property_number_of_bedrooms_spec.rb | 0 .../questions/property_number_of_bedrooms_spec.rb | 0 spec/models/form_handler_spec.rb | 4 ++-- 6 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 app/models/form/sales/property/sections/property_information.rb create mode 100644 app/models/form/sales/property/subsections/property_information.rb rename spec/models/form/sales/{ => property}/pages/property_number_of_bedrooms_spec.rb (100%) rename spec/models/form/sales/{ => property}/questions/property_number_of_bedrooms_spec.rb (100%) diff --git a/app/models/form/sales/property/sections/property_information.rb b/app/models/form/sales/property/sections/property_information.rb new file mode 100644 index 000000000..eab4faac6 --- /dev/null +++ b/app/models/form/sales/property/sections/property_information.rb @@ -0,0 +1,10 @@ +class Form::Sales::Property::Sections::PropertyInformation < ::Form::Section + def initialize(id, hsh, form) + super + @id = "property_information" + @label = "Property information" + @description = "" + @form = form + @subsections = [Form::Sales::Property::Subsections::PropertyInformation.new(nil, nil, self)] || [] + end +end diff --git a/app/models/form/sales/property/subsections/property_information.rb b/app/models/form/sales/property/subsections/property_information.rb new file mode 100644 index 000000000..6abe162cb --- /dev/null +++ b/app/models/form/sales/property/subsections/property_information.rb @@ -0,0 +1,15 @@ +class Form::Sales::Property::Subsections::PropertyInformation < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "property_information" + @label = "Property information" + @section = section + @depends_on = [ { "setup" => "completed" } ] + end + + def pages + @pages ||= [ + Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), + ] + end +end diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index 40d993cd6..a4deaf25c 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -19,7 +19,7 @@ class FormHandler end def sales_forms - sales_sections = [] # Add section classes here e.g. Form::Sales::Property::Sections::PropertyInformation + sales_sections = [Form::Sales::Property::Sections::PropertyInformation] # Add section classes here e.g. Form::Sales::Property::Sections::PropertyInformation current_form = Form.new(nil, current_collection_start_year, sales_sections, "sales") previous_form = Form.new(nil, current_collection_start_year - 1, sales_sections, "sales") { "current_sales" => current_form, diff --git a/spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb b/spec/models/form/sales/property/pages/property_number_of_bedrooms_spec.rb similarity index 100% rename from spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb rename to spec/models/form/sales/property/pages/property_number_of_bedrooms_spec.rb diff --git a/spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb b/spec/models/form/sales/property/questions/property_number_of_bedrooms_spec.rb similarity index 100% rename from spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb rename to spec/models/form/sales/property/questions/property_number_of_bedrooms_spec.rb diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 55d39e4e4..289899a1e 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -61,14 +61,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(10) + expect(form.pages.count).to eq(11) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(10) + expect(form.pages.count).to eq(11) expect(form.name).to eq("2021_2022_sales") end end