Browse Source

move beds question to property section

pull/890/head
Ted-U 3 years ago
parent
commit
067de660af
  1. 10
      app/models/form/sales/property/sections/property_information.rb
  2. 15
      app/models/form/sales/property/subsections/property_information.rb
  3. 2
      app/models/form_handler.rb
  4. 0
      spec/models/form/sales/property/pages/property_number_of_bedrooms_spec.rb
  5. 0
      spec/models/form/sales/property/questions/property_number_of_bedrooms_spec.rb
  6. 4
      spec/models/form_handler_spec.rb

10
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

15
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

2
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,

0
spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb → spec/models/form/sales/property/pages/property_number_of_bedrooms_spec.rb

0
spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb → spec/models/form/sales/property/questions/property_number_of_bedrooms_spec.rb

4
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

Loading…
Cancel
Save