From 1664493287162923ba4be70b72cbec6c7109a75c Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Thu, 15 Sep 2022 13:14:52 +0100 Subject: [PATCH] Refactor form namespacing (#873) * Refactor form namespacing * Extract common questions --- app/models/form.rb | 6 +-- .../{setup => common}/pages/created_by.rb | 4 +- .../{setup => common}/pages/organisation.rb | 4 +- .../questions/created_by_id.rb | 2 +- .../questions/owning_organisation_id.rb | 2 +- .../{setup => lettings}/pages/location.rb | 4 +- .../{setup => lettings}/pages/needs_type.rb | 4 +- .../pages/property_reference.rb | 4 +- .../form/{setup => lettings}/pages/renewal.rb | 4 +- .../{setup => lettings}/pages/rent_type.rb | 6 +-- .../form/{setup => lettings}/pages/scheme.rb | 4 +- .../pages/tenancy_start_date.rb | 4 +- .../{setup => lettings}/pages/tenant_code.rb | 4 +- .../questions/irproduct_other.rb | 2 +- .../questions/location_id.rb | 2 +- .../questions/needs_type.rb | 2 +- .../questions/property_reference.rb | 2 +- .../{setup => lettings}/questions/renewal.rb | 2 +- .../questions/rent_type.rb | 2 +- .../questions/scheme_id.rb | 2 +- .../questions/tenancy_start_date.rb | 2 +- .../questions/tenant_code.rb | 2 +- .../{setup => lettings}/sections/setup.rb | 4 +- app/models/form/lettings/subsections/setup.rb | 37 +++++++++++++++++++ .../sales/{setup => }/pages/purchaser_code.rb | 4 +- .../form/sales/{setup => }/pages/sale_date.rb | 4 +- .../{setup => }/questions/purchaser_code.rb | 2 +- .../sales/{setup => }/questions/sale_date.rb | 2 +- app/models/form/sales/sections/setup.rb | 10 +++++ app/models/form/sales/setup/sections/setup.rb | 10 ----- .../form/sales/setup/subsections/setup.rb | 15 -------- app/models/form/sales/subsections/setup.rb | 15 ++++++++ app/models/form/setup/subsections/setup.rb | 37 ------------------- .../pages/created_by_spec.rb | 2 +- .../pages/organisation_spec.rb | 2 +- .../questions/created_by_id_spec.rb | 2 +- .../questions/owning_organisation_id_spec.rb | 2 +- .../pages/location_spec.rb | 2 +- .../pages/needs_type_spec.rb | 2 +- .../pages/property_reference_spec.rb | 2 +- .../{setup => lettings}/pages/renewal_spec.rb | 2 +- .../pages/rent_type_spec.rb | 2 +- .../{setup => lettings}/pages/scheme_spec.rb | 2 +- .../pages/tenancy_start_date_spec.rb | 2 +- .../pages/tenant_code_spec.rb | 2 +- .../questions/irproduct_other_spec.rb | 2 +- .../questions/location_id_spec.rb | 2 +- .../questions/needs_type_spec.rb | 2 +- .../questions/property_reference_spec.rb | 2 +- .../questions/renewal_spec.rb | 2 +- .../questions/rent_type_spec.rb | 2 +- .../questions/scheme_id_spec.rb | 2 +- .../questions/tenancy_start_date_spec.rb | 2 +- .../questions/tenant_code_spec.rb | 2 +- .../setup => lettings}/sections/setup_spec.rb | 2 +- .../subsections/setup_spec.rb | 4 +- .../{setup => }/pages/purchaser_code_spec.rb | 2 +- .../sales/{setup => }/pages/sale_date_spec.rb | 2 +- .../questions/purchaser_code_spec.rb | 2 +- .../{setup => }/questions/sale_date_spec.rb | 2 +- .../{setup => sales}/sections/setup_spec.rb | 2 +- .../{setup => }/subsections/setup_spec.rb | 4 +- spec/models/form_spec.rb | 4 +- 63 files changed, 137 insertions(+), 139 deletions(-) rename app/models/form/{setup => common}/pages/created_by.rb (70%) rename app/models/form/{setup => common}/pages/organisation.rb (68%) rename app/models/form/{setup => common}/questions/created_by_id.rb (94%) rename app/models/form/{setup => common}/questions/owning_organisation_id.rb (92%) rename app/models/form/{setup => lettings}/pages/location.rb (70%) rename app/models/form/{setup => lettings}/pages/needs_type.rb (62%) rename app/models/form/{setup => lettings}/pages/property_reference.rb (60%) rename app/models/form/{setup => lettings}/pages/renewal.rb (63%) rename app/models/form/{setup => lettings}/pages/rent_type.rb (51%) rename app/models/form/{setup => lettings}/pages/scheme.rb (66%) rename app/models/form/{setup => lettings}/pages/tenancy_start_date.rb (59%) rename app/models/form/{setup => lettings}/pages/tenant_code.rb (62%) rename app/models/form/{setup => lettings}/questions/irproduct_other.rb (74%) rename app/models/form/{setup => lettings}/questions/location_id.rb (95%) rename app/models/form/{setup => lettings}/questions/needs_type.rb (90%) rename app/models/form/{setup => lettings}/questions/property_reference.rb (81%) rename app/models/form/{setup => lettings}/questions/renewal.rb (85%) rename app/models/form/{setup => lettings}/questions/rent_type.rb (91%) rename app/models/form/{setup => lettings}/questions/scheme_id.rb (96%) rename app/models/form/{setup => lettings}/questions/tenancy_start_date.rb (74%) rename app/models/form/{setup => lettings}/questions/tenant_code.rb (82%) rename app/models/form/{setup => lettings}/sections/setup.rb (51%) create mode 100644 app/models/form/lettings/subsections/setup.rb rename app/models/form/sales/{setup => }/pages/purchaser_code.rb (60%) rename app/models/form/sales/{setup => }/pages/sale_date.rb (61%) rename app/models/form/sales/{setup => }/questions/purchaser_code.rb (75%) rename app/models/form/sales/{setup => }/questions/sale_date.rb (76%) create mode 100644 app/models/form/sales/sections/setup.rb delete mode 100644 app/models/form/sales/setup/sections/setup.rb delete mode 100644 app/models/form/sales/setup/subsections/setup.rb create mode 100644 app/models/form/sales/subsections/setup.rb delete mode 100644 app/models/form/setup/subsections/setup.rb rename spec/models/form/{setup => common}/pages/created_by_spec.rb (95%) rename spec/models/form/{setup => common}/pages/organisation_spec.rb (95%) rename spec/models/form/{setup => common}/questions/created_by_id_spec.rb (97%) rename spec/models/form/{setup => common}/questions/owning_organisation_id_spec.rb (97%) rename spec/models/form/{setup => lettings}/pages/location_spec.rb (92%) rename spec/models/form/{setup => lettings}/pages/needs_type_spec.rb (90%) rename spec/models/form/{setup => lettings}/pages/property_reference_spec.rb (90%) rename spec/models/form/{setup => lettings}/pages/renewal_spec.rb (91%) rename spec/models/form/{setup => lettings}/pages/rent_type_spec.rb (91%) rename spec/models/form/{setup => lettings}/pages/scheme_spec.rb (91%) rename spec/models/form/{setup => lettings}/pages/tenancy_start_date_spec.rb (91%) rename spec/models/form/{setup => lettings}/pages/tenant_code_spec.rb (91%) rename spec/models/form/{setup => lettings}/questions/irproduct_other_spec.rb (91%) rename spec/models/form/{setup => lettings}/questions/location_id_spec.rb (97%) rename spec/models/form/{setup => lettings}/questions/needs_type_spec.rb (93%) rename spec/models/form/{setup => lettings}/questions/property_reference_spec.rb (93%) rename spec/models/form/{setup => lettings}/questions/renewal_spec.rb (93%) rename spec/models/form/{setup => lettings}/questions/rent_type_spec.rb (95%) rename spec/models/form/{setup => lettings}/questions/scheme_id_spec.rb (98%) rename spec/models/form/{setup => lettings}/questions/tenancy_start_date_spec.rb (90%) rename spec/models/form/{setup => lettings}/questions/tenant_code_spec.rb (93%) rename spec/models/form/{sales/setup => lettings}/sections/setup_spec.rb (90%) rename spec/models/form/{setup => lettings}/subsections/setup_spec.rb (84%) rename spec/models/form/sales/{setup => }/pages/purchaser_code_spec.rb (89%) rename spec/models/form/sales/{setup => }/pages/sale_date_spec.rb (90%) rename spec/models/form/sales/{setup => }/questions/purchaser_code_spec.rb (91%) rename spec/models/form/sales/{setup => }/questions/sale_date_spec.rb (91%) rename spec/models/form/{setup => sales}/sections/setup_spec.rb (91%) rename spec/models/form/sales/{setup => }/subsections/setup_spec.rb (79%) diff --git a/app/models/form.rb b/app/models/form.rb index a463e497f..549415dd4 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -3,12 +3,10 @@ class Form :start_date, :end_date, :type, :name, :setup_definition, :setup_sections, :form_sections - include Form::Setup - def initialize(form_path, name, sections_in_form = [], type = "lettings") if type == "sales" @name = name - @setup_sections = [Form::Sales::Setup::Sections::Setup.new(nil, nil, self)] + @setup_sections = [Form::Sales::Sections::Setup.new(nil, nil, self)] @form_sections = sections_in_form.map { |sec| sec.new(nil, nil, self) } @type = "sales" @sections = setup_sections + form_sections @@ -27,7 +25,7 @@ class Form raise "No form definition file exists for given year".freeze unless File.exist?(form_path) @name = name - @setup_sections = [Form::Setup::Sections::Setup.new(nil, nil, self)] + @setup_sections = [Form::Lettings::Sections::Setup.new(nil, nil, self)] @form_definition = JSON.parse(File.open(form_path).read) @form_sections = form_definition["sections"].map { |id, s| Form::Section.new(id, s, self) } @type = form_definition["form_type"] diff --git a/app/models/form/setup/pages/created_by.rb b/app/models/form/common/pages/created_by.rb similarity index 70% rename from app/models/form/setup/pages/created_by.rb rename to app/models/form/common/pages/created_by.rb index 979171e5d..e02f97740 100644 --- a/app/models/form/setup/pages/created_by.rb +++ b/app/models/form/common/pages/created_by.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::CreatedBy < ::Form::Page +class Form::Common::Pages::CreatedBy < ::Form::Page def initialize(id, hsh, subsection) super @id = "created_by" @@ -9,7 +9,7 @@ class Form::Setup::Pages::CreatedBy < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::CreatedById.new(nil, nil, self), + Form::Common::Questions::CreatedById.new(nil, nil, self), ] end diff --git a/app/models/form/setup/pages/organisation.rb b/app/models/form/common/pages/organisation.rb similarity index 68% rename from app/models/form/setup/pages/organisation.rb rename to app/models/form/common/pages/organisation.rb index 4844627c2..48b157a56 100644 --- a/app/models/form/setup/pages/organisation.rb +++ b/app/models/form/common/pages/organisation.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::Organisation < ::Form::Page +class Form::Common::Pages::Organisation < ::Form::Page def initialize(id, hsh, subsection) super @id = "organisation" @@ -9,7 +9,7 @@ class Form::Setup::Pages::Organisation < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::OwningOrganisationId.new(nil, nil, self), + Form::Common::Questions::OwningOrganisationId.new(nil, nil, self), ] end diff --git a/app/models/form/setup/questions/created_by_id.rb b/app/models/form/common/questions/created_by_id.rb similarity index 94% rename from app/models/form/setup/questions/created_by_id.rb rename to app/models/form/common/questions/created_by_id.rb index f25d4917c..b0558e5e2 100644 --- a/app/models/form/setup/questions/created_by_id.rb +++ b/app/models/form/common/questions/created_by_id.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::CreatedById < ::Form::Question +class Form::Common::Questions::CreatedById < ::Form::Question def initialize(id, hsh, page) super @id = "created_by_id" diff --git a/app/models/form/setup/questions/owning_organisation_id.rb b/app/models/form/common/questions/owning_organisation_id.rb similarity index 92% rename from app/models/form/setup/questions/owning_organisation_id.rb rename to app/models/form/common/questions/owning_organisation_id.rb index ea3da3e25..84eefbf21 100644 --- a/app/models/form/setup/questions/owning_organisation_id.rb +++ b/app/models/form/common/questions/owning_organisation_id.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::OwningOrganisationId < ::Form::Question +class Form::Common::Questions::OwningOrganisationId < ::Form::Question def initialize(id, hsh, page) super @id = "owning_organisation_id" diff --git a/app/models/form/setup/pages/location.rb b/app/models/form/lettings/pages/location.rb similarity index 70% rename from app/models/form/setup/pages/location.rb rename to app/models/form/lettings/pages/location.rb index 7acbc1bbe..982f4c109 100644 --- a/app/models/form/setup/pages/location.rb +++ b/app/models/form/lettings/pages/location.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::Location < ::Form::Page +class Form::Lettings::Pages::Location < ::Form::Page def initialize(_id, hsh, subsection) super("location", hsh, subsection) @header = "" @@ -11,7 +11,7 @@ class Form::Setup::Pages::Location < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::LocationId.new(nil, nil, self), + Form::Lettings::Questions::LocationId.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/needs_type.rb b/app/models/form/lettings/pages/needs_type.rb similarity index 62% rename from app/models/form/setup/pages/needs_type.rb rename to app/models/form/lettings/pages/needs_type.rb index 2625d6cda..0a67d831b 100644 --- a/app/models/form/setup/pages/needs_type.rb +++ b/app/models/form/lettings/pages/needs_type.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::NeedsType < ::Form::Page +class Form::Lettings::Pages::NeedsType < ::Form::Page def initialize(id, hsh, subsection) super @id = "needs_type" @@ -9,7 +9,7 @@ class Form::Setup::Pages::NeedsType < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::NeedsType.new(nil, nil, self), + Form::Lettings::Questions::NeedsType.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/property_reference.rb b/app/models/form/lettings/pages/property_reference.rb similarity index 60% rename from app/models/form/setup/pages/property_reference.rb rename to app/models/form/lettings/pages/property_reference.rb index 14fafade2..150974ee8 100644 --- a/app/models/form/setup/pages/property_reference.rb +++ b/app/models/form/lettings/pages/property_reference.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::PropertyReference < ::Form::Page +class Form::Lettings::Pages::PropertyReference < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_reference" @@ -9,7 +9,7 @@ class Form::Setup::Pages::PropertyReference < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::PropertyReference.new(nil, nil, self), + Form::Lettings::Questions::PropertyReference.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/renewal.rb b/app/models/form/lettings/pages/renewal.rb similarity index 63% rename from app/models/form/setup/pages/renewal.rb rename to app/models/form/lettings/pages/renewal.rb index 8a627d7c9..873ff8822 100644 --- a/app/models/form/setup/pages/renewal.rb +++ b/app/models/form/lettings/pages/renewal.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::Renewal < ::Form::Page +class Form::Lettings::Pages::Renewal < ::Form::Page def initialize(id, hsh, subsection) super @id = "renewal" @@ -9,7 +9,7 @@ class Form::Setup::Pages::Renewal < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::Renewal.new(nil, nil, self), + Form::Lettings::Questions::Renewal.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/rent_type.rb b/app/models/form/lettings/pages/rent_type.rb similarity index 51% rename from app/models/form/setup/pages/rent_type.rb rename to app/models/form/lettings/pages/rent_type.rb index 5e112c3c6..d1ac4de99 100644 --- a/app/models/form/setup/pages/rent_type.rb +++ b/app/models/form/lettings/pages/rent_type.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::RentType < ::Form::Page +class Form::Lettings::Pages::RentType < ::Form::Page def initialize(_id, hsh, subsection) super("rent_type", hsh, subsection) @header = "" @@ -8,8 +8,8 @@ class Form::Setup::Pages::RentType < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::RentType.new(nil, nil, self), - Form::Setup::Questions::IrproductOther.new(nil, nil, self), + Form::Lettings::Questions::RentType.new(nil, nil, self), + Form::Lettings::Questions::IrproductOther.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/scheme.rb b/app/models/form/lettings/pages/scheme.rb similarity index 66% rename from app/models/form/setup/pages/scheme.rb rename to app/models/form/lettings/pages/scheme.rb index e71a8d424..c17eaab04 100644 --- a/app/models/form/setup/pages/scheme.rb +++ b/app/models/form/lettings/pages/scheme.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::Scheme < ::Form::Page +class Form::Lettings::Pages::Scheme < ::Form::Page def initialize(_id, hsh, subsection) super("scheme", hsh, subsection) @header = "" @@ -10,7 +10,7 @@ class Form::Setup::Pages::Scheme < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::SchemeId.new(nil, nil, self), + Form::Lettings::Questions::SchemeId.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/tenancy_start_date.rb b/app/models/form/lettings/pages/tenancy_start_date.rb similarity index 59% rename from app/models/form/setup/pages/tenancy_start_date.rb rename to app/models/form/lettings/pages/tenancy_start_date.rb index 117ef8452..562153dc2 100644 --- a/app/models/form/setup/pages/tenancy_start_date.rb +++ b/app/models/form/lettings/pages/tenancy_start_date.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::TenancyStartDate < ::Form::Page +class Form::Lettings::Pages::TenancyStartDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_start_date" @@ -8,7 +8,7 @@ class Form::Setup::Pages::TenancyStartDate < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::TenancyStartDate.new(nil, nil, self), + Form::Lettings::Questions::TenancyStartDate.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/pages/tenant_code.rb b/app/models/form/lettings/pages/tenant_code.rb similarity index 62% rename from app/models/form/setup/pages/tenant_code.rb rename to app/models/form/lettings/pages/tenant_code.rb index f7b8350d1..67771514a 100644 --- a/app/models/form/setup/pages/tenant_code.rb +++ b/app/models/form/lettings/pages/tenant_code.rb @@ -1,4 +1,4 @@ -class Form::Setup::Pages::TenantCode < ::Form::Page +class Form::Lettings::Pages::TenantCode < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenant_code" @@ -9,7 +9,7 @@ class Form::Setup::Pages::TenantCode < ::Form::Page def questions @questions ||= [ - Form::Setup::Questions::TenantCode.new(nil, nil, self), + Form::Lettings::Questions::TenantCode.new(nil, nil, self), ] end end diff --git a/app/models/form/setup/questions/irproduct_other.rb b/app/models/form/lettings/questions/irproduct_other.rb similarity index 74% rename from app/models/form/setup/questions/irproduct_other.rb rename to app/models/form/lettings/questions/irproduct_other.rb index 10c44d1fc..7607d6d9c 100644 --- a/app/models/form/setup/questions/irproduct_other.rb +++ b/app/models/form/lettings/questions/irproduct_other.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::IrproductOther < ::Form::Question +class Form::Lettings::Questions::IrproductOther < ::Form::Question def initialize(id, hsh, page) super @id = "irproduct_other" diff --git a/app/models/form/setup/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb similarity index 95% rename from app/models/form/setup/questions/location_id.rb rename to app/models/form/lettings/questions/location_id.rb index 58afbe011..cae6463a9 100644 --- a/app/models/form/setup/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::LocationId < ::Form::Question +class Form::Lettings::Questions::LocationId < ::Form::Question def initialize(_id, hsh, page) super("location_id", hsh, page) @check_answer_label = "Location" diff --git a/app/models/form/setup/questions/needs_type.rb b/app/models/form/lettings/questions/needs_type.rb similarity index 90% rename from app/models/form/setup/questions/needs_type.rb rename to app/models/form/lettings/questions/needs_type.rb index 01c52b8cc..46949a2bf 100644 --- a/app/models/form/setup/questions/needs_type.rb +++ b/app/models/form/lettings/questions/needs_type.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::NeedsType < ::Form::Question +class Form::Lettings::Questions::NeedsType < ::Form::Question def initialize(id, hsh, page) super @id = "needstype" diff --git a/app/models/form/setup/questions/property_reference.rb b/app/models/form/lettings/questions/property_reference.rb similarity index 81% rename from app/models/form/setup/questions/property_reference.rb rename to app/models/form/lettings/questions/property_reference.rb index c52bf1a16..40517b9d3 100644 --- a/app/models/form/setup/questions/property_reference.rb +++ b/app/models/form/lettings/questions/property_reference.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::PropertyReference < ::Form::Question +class Form::Lettings::Questions::PropertyReference < ::Form::Question def initialize(id, hsh, page) super @id = "propcode" diff --git a/app/models/form/setup/questions/renewal.rb b/app/models/form/lettings/questions/renewal.rb similarity index 85% rename from app/models/form/setup/questions/renewal.rb rename to app/models/form/lettings/questions/renewal.rb index 53b68fb68..06b5f0ff4 100644 --- a/app/models/form/setup/questions/renewal.rb +++ b/app/models/form/lettings/questions/renewal.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::Renewal < ::Form::Question +class Form::Lettings::Questions::Renewal < ::Form::Question def initialize(id, hsh, page) super @id = "renewal" diff --git a/app/models/form/setup/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb similarity index 91% rename from app/models/form/setup/questions/rent_type.rb rename to app/models/form/lettings/questions/rent_type.rb index c69b1a100..c7c23c74b 100644 --- a/app/models/form/setup/questions/rent_type.rb +++ b/app/models/form/lettings/questions/rent_type.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::RentType < ::Form::Question +class Form::Lettings::Questions::RentType < ::Form::Question def initialize(id, hsh, page) super @id = "rent_type" diff --git a/app/models/form/setup/questions/scheme_id.rb b/app/models/form/lettings/questions/scheme_id.rb similarity index 96% rename from app/models/form/setup/questions/scheme_id.rb rename to app/models/form/lettings/questions/scheme_id.rb index 9a71e1559..064be8032 100644 --- a/app/models/form/setup/questions/scheme_id.rb +++ b/app/models/form/lettings/questions/scheme_id.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::SchemeId < ::Form::Question +class Form::Lettings::Questions::SchemeId < ::Form::Question def initialize(_id, hsh, page) super("scheme_id", hsh, page) @check_answer_label = "Scheme name" diff --git a/app/models/form/setup/questions/tenancy_start_date.rb b/app/models/form/lettings/questions/tenancy_start_date.rb similarity index 74% rename from app/models/form/setup/questions/tenancy_start_date.rb rename to app/models/form/lettings/questions/tenancy_start_date.rb index 8e05771f7..f7e2622ac 100644 --- a/app/models/form/setup/questions/tenancy_start_date.rb +++ b/app/models/form/lettings/questions/tenancy_start_date.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::TenancyStartDate < ::Form::Question +class Form::Lettings::Questions::TenancyStartDate < ::Form::Question def initialize(id, hsh, page) super @id = "startdate" diff --git a/app/models/form/setup/questions/tenant_code.rb b/app/models/form/lettings/questions/tenant_code.rb similarity index 82% rename from app/models/form/setup/questions/tenant_code.rb rename to app/models/form/lettings/questions/tenant_code.rb index e299a3991..dcbbb72a8 100644 --- a/app/models/form/setup/questions/tenant_code.rb +++ b/app/models/form/lettings/questions/tenant_code.rb @@ -1,4 +1,4 @@ -class Form::Setup::Questions::TenantCode < ::Form::Question +class Form::Lettings::Questions::TenantCode < ::Form::Question def initialize(id, hsh, page) super @id = "tenancycode" diff --git a/app/models/form/setup/sections/setup.rb b/app/models/form/lettings/sections/setup.rb similarity index 51% rename from app/models/form/setup/sections/setup.rb rename to app/models/form/lettings/sections/setup.rb index 9e41eb2bb..e278ad1e3 100644 --- a/app/models/form/setup/sections/setup.rb +++ b/app/models/form/lettings/sections/setup.rb @@ -1,10 +1,10 @@ -class Form::Sections::Setup < ::Form::Section +class Form::Lettings::Sections::Setup < ::Form::Section def initialize(id, hsh, form) super @id = "setup" @label = "Before you start" @description = "" @form = form - @subsections = [Form::Setup::Subsections::Setup.new(nil, nil, self)] + @subsections = [Form::Lettings::Subsections::Setup.new(nil, nil, self)] end end diff --git a/app/models/form/lettings/subsections/setup.rb b/app/models/form/lettings/subsections/setup.rb new file mode 100644 index 000000000..79d346599 --- /dev/null +++ b/app/models/form/lettings/subsections/setup.rb @@ -0,0 +1,37 @@ +class Form::Lettings::Subsections::Setup < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "setup" + @label = "Set up this lettings log" + @section = section + end + + def pages + @pages ||= [ + Form::Common::Pages::Organisation.new(nil, nil, self), + Form::Common::Pages::CreatedBy.new(nil, nil, self), + Form::Lettings::Pages::NeedsType.new(nil, nil, self), + Form::Lettings::Pages::Scheme.new(nil, nil, self), + Form::Lettings::Pages::Location.new(nil, nil, self), + Form::Lettings::Pages::Renewal.new(nil, nil, self), + Form::Lettings::Pages::TenancyStartDate.new(nil, nil, self), + Form::Lettings::Pages::RentType.new(nil, nil, self), + Form::Lettings::Pages::TenantCode.new(nil, nil, self), + Form::Lettings::Pages::PropertyReference.new(nil, nil, self), + ] + end + + def applicable_questions(lettings_log) + questions.select { |q| support_only_questions.include?(q.id) } + super + end + + def enabled?(_lettings_log) + true + end + +private + + def support_only_questions + %w[owning_organisation_id created_by_id].freeze + end +end diff --git a/app/models/form/sales/setup/pages/purchaser_code.rb b/app/models/form/sales/pages/purchaser_code.rb similarity index 60% rename from app/models/form/sales/setup/pages/purchaser_code.rb rename to app/models/form/sales/pages/purchaser_code.rb index f70c71e96..79723e0b0 100644 --- a/app/models/form/sales/setup/pages/purchaser_code.rb +++ b/app/models/form/sales/pages/purchaser_code.rb @@ -1,4 +1,4 @@ -class Form::Sales::Setup::Pages::PurchaserCode < ::Form::Page +class Form::Sales::Pages::PurchaserCode < ::Form::Page def initialize(id, hsh, subsection) super @id = "purchaser_code" @@ -9,7 +9,7 @@ class Form::Sales::Setup::Pages::PurchaserCode < ::Form::Page def questions @questions ||= [ - Form::Sales::Setup::Questions::PurchaserCode.new(nil, nil, self), + Form::Sales::Questions::PurchaserCode.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/setup/pages/sale_date.rb b/app/models/form/sales/pages/sale_date.rb similarity index 61% rename from app/models/form/sales/setup/pages/sale_date.rb rename to app/models/form/sales/pages/sale_date.rb index 4cdfe5a71..814684e2e 100644 --- a/app/models/form/sales/setup/pages/sale_date.rb +++ b/app/models/form/sales/pages/sale_date.rb @@ -1,4 +1,4 @@ -class Form::Sales::Setup::Pages::SaleDate < ::Form::Page +class Form::Sales::Pages::SaleDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "sale_date" @@ -9,7 +9,7 @@ class Form::Sales::Setup::Pages::SaleDate < ::Form::Page def questions @questions ||= [ - Form::Sales::Setup::Questions::SaleDate.new(nil, nil, self), + Form::Sales::Questions::SaleDate.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/setup/questions/purchaser_code.rb b/app/models/form/sales/questions/purchaser_code.rb similarity index 75% rename from app/models/form/sales/setup/questions/purchaser_code.rb rename to app/models/form/sales/questions/purchaser_code.rb index 409ed6ac1..b391faf21 100644 --- a/app/models/form/sales/setup/questions/purchaser_code.rb +++ b/app/models/form/sales/questions/purchaser_code.rb @@ -1,4 +1,4 @@ -class Form::Sales::Setup::Questions::PurchaserCode < ::Form::Question +class Form::Sales::Questions::PurchaserCode < ::Form::Question def initialize(id, hsh, page) super @id = "purchid" diff --git a/app/models/form/sales/setup/questions/sale_date.rb b/app/models/form/sales/questions/sale_date.rb similarity index 76% rename from app/models/form/sales/setup/questions/sale_date.rb rename to app/models/form/sales/questions/sale_date.rb index 4f9088aaf..2b0a3d171 100644 --- a/app/models/form/sales/setup/questions/sale_date.rb +++ b/app/models/form/sales/questions/sale_date.rb @@ -1,4 +1,4 @@ -class Form::Sales::Setup::Questions::SaleDate < ::Form::Question +class Form::Sales::Questions::SaleDate < ::Form::Question def initialize(id, hsh, page) super @id = "saledate" diff --git a/app/models/form/sales/sections/setup.rb b/app/models/form/sales/sections/setup.rb new file mode 100644 index 000000000..d90c72036 --- /dev/null +++ b/app/models/form/sales/sections/setup.rb @@ -0,0 +1,10 @@ +class Form::Sales::Sections::Setup < ::Form::Section + def initialize(id, hsh, form) + super + @id = "setup" + @label = "Before you start" + @description = "" + @form = form + @subsections = [Form::Sales::Subsections::Setup.new(nil, nil, self)] || [] + end +end diff --git a/app/models/form/sales/setup/sections/setup.rb b/app/models/form/sales/setup/sections/setup.rb deleted file mode 100644 index 42835ec39..000000000 --- a/app/models/form/sales/setup/sections/setup.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Form::Sales::Setup::Sections::Setup < ::Form::Section - def initialize(id, hsh, form) - super - @id = "setup" - @label = "Before you start" - @description = "" - @form = form - @subsections = [Form::Sales::Setup::Subsections::Setup.new(nil, nil, self)] || [] - end -end diff --git a/app/models/form/sales/setup/subsections/setup.rb b/app/models/form/sales/setup/subsections/setup.rb deleted file mode 100644 index f2df0b9f4..000000000 --- a/app/models/form/sales/setup/subsections/setup.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Form::Sales::Setup::Subsections::Setup < ::Form::Subsection - def initialize(id, hsh, section) - super - @id = "setup" - @label = "Set up this sales log" - @section = section - end - - def pages - @pages ||= [ - Form::Sales::Setup::Pages::PurchaserCode.new(nil, nil, self), - Form::Sales::Setup::Pages::SaleDate.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb new file mode 100644 index 000000000..42eac8f6f --- /dev/null +++ b/app/models/form/sales/subsections/setup.rb @@ -0,0 +1,15 @@ +class Form::Sales::Subsections::Setup < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "setup" + @label = "Set up this sales log" + @section = section + end + + def pages + @pages ||= [ + Form::Sales::Pages::PurchaserCode.new(nil, nil, self), + Form::Sales::Pages::SaleDate.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/setup/subsections/setup.rb b/app/models/form/setup/subsections/setup.rb deleted file mode 100644 index 7bc4a079d..000000000 --- a/app/models/form/setup/subsections/setup.rb +++ /dev/null @@ -1,37 +0,0 @@ -class Form::Subsections::Setup < ::Form::Subsection - def initialize(id, hsh, section) - super - @id = "setup" - @label = "Set up this lettings log" - @section = section - end - - def pages - @pages ||= [ - Form::Setup::Pages::Organisation.new(nil, nil, self), - Form::Setup::Pages::CreatedBy.new(nil, nil, self), - Form::Setup::Pages::NeedsType.new(nil, nil, self), - Form::Setup::Pages::Scheme.new(nil, nil, self), - Form::Setup::Pages::Location.new(nil, nil, self), - Form::Setup::Pages::Renewal.new(nil, nil, self), - Form::Setup::Pages::TenancyStartDate.new(nil, nil, self), - Form::Setup::Pages::RentType.new(nil, nil, self), - Form::Setup::Pages::TenantCode.new(nil, nil, self), - Form::Setup::Pages::PropertyReference.new(nil, nil, self), - ] - end - - def applicable_questions(lettings_log) - questions.select { |q| support_only_questions.include?(q.id) } + super - end - - def enabled?(_lettings_log) - true - end - -private - - def support_only_questions - %w[owning_organisation_id created_by_id].freeze - end -end diff --git a/spec/models/form/setup/pages/created_by_spec.rb b/spec/models/form/common/pages/created_by_spec.rb similarity index 95% rename from spec/models/form/setup/pages/created_by_spec.rb rename to spec/models/form/common/pages/created_by_spec.rb index 7ae803d0d..1f11a5889 100644 --- a/spec/models/form/setup/pages/created_by_spec.rb +++ b/spec/models/form/common/pages/created_by_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::CreatedBy, type: :model do +RSpec.describe Form::Common::Pages::CreatedBy, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/organisation_spec.rb b/spec/models/form/common/pages/organisation_spec.rb similarity index 95% rename from spec/models/form/setup/pages/organisation_spec.rb rename to spec/models/form/common/pages/organisation_spec.rb index 50d8b90fd..ae7a1027c 100644 --- a/spec/models/form/setup/pages/organisation_spec.rb +++ b/spec/models/form/common/pages/organisation_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::Organisation, type: :model do +RSpec.describe Form::Common::Pages::Organisation, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/questions/created_by_id_spec.rb b/spec/models/form/common/questions/created_by_id_spec.rb similarity index 97% rename from spec/models/form/setup/questions/created_by_id_spec.rb rename to spec/models/form/common/questions/created_by_id_spec.rb index 95203a555..b00e21f90 100644 --- a/spec/models/form/setup/questions/created_by_id_spec.rb +++ b/spec/models/form/common/questions/created_by_id_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::CreatedById, type: :model do +RSpec.describe Form::Common::Questions::CreatedById, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/owning_organisation_id_spec.rb b/spec/models/form/common/questions/owning_organisation_id_spec.rb similarity index 97% rename from spec/models/form/setup/questions/owning_organisation_id_spec.rb rename to spec/models/form/common/questions/owning_organisation_id_spec.rb index 8c74a169d..9ee32e342 100644 --- a/spec/models/form/setup/questions/owning_organisation_id_spec.rb +++ b/spec/models/form/common/questions/owning_organisation_id_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::OwningOrganisationId, type: :model do +RSpec.describe Form::Common::Questions::OwningOrganisationId, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/pages/location_spec.rb b/spec/models/form/lettings/pages/location_spec.rb similarity index 92% rename from spec/models/form/setup/pages/location_spec.rb rename to spec/models/form/lettings/pages/location_spec.rb index 10db3d331..bdf08c244 100644 --- a/spec/models/form/setup/pages/location_spec.rb +++ b/spec/models/form/lettings/pages/location_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::Location, type: :model do +RSpec.describe Form::Lettings::Pages::Location, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/needs_type_spec.rb b/spec/models/form/lettings/pages/needs_type_spec.rb similarity index 90% rename from spec/models/form/setup/pages/needs_type_spec.rb rename to spec/models/form/lettings/pages/needs_type_spec.rb index 772c2a11d..37978fdf8 100644 --- a/spec/models/form/setup/pages/needs_type_spec.rb +++ b/spec/models/form/lettings/pages/needs_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::NeedsType, type: :model do +RSpec.describe Form::Lettings::Pages::NeedsType, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/property_reference_spec.rb b/spec/models/form/lettings/pages/property_reference_spec.rb similarity index 90% rename from spec/models/form/setup/pages/property_reference_spec.rb rename to spec/models/form/lettings/pages/property_reference_spec.rb index 555ee97f2..cb2f2c76a 100644 --- a/spec/models/form/setup/pages/property_reference_spec.rb +++ b/spec/models/form/lettings/pages/property_reference_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::PropertyReference, type: :model do +RSpec.describe Form::Lettings::Pages::PropertyReference, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/renewal_spec.rb b/spec/models/form/lettings/pages/renewal_spec.rb similarity index 91% rename from spec/models/form/setup/pages/renewal_spec.rb rename to spec/models/form/lettings/pages/renewal_spec.rb index f37cb3ef1..0fceb1a99 100644 --- a/spec/models/form/setup/pages/renewal_spec.rb +++ b/spec/models/form/lettings/pages/renewal_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::Renewal, type: :model do +RSpec.describe Form::Lettings::Pages::Renewal, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/rent_type_spec.rb b/spec/models/form/lettings/pages/rent_type_spec.rb similarity index 91% rename from spec/models/form/setup/pages/rent_type_spec.rb rename to spec/models/form/lettings/pages/rent_type_spec.rb index d558ea75c..6541d542d 100644 --- a/spec/models/form/setup/pages/rent_type_spec.rb +++ b/spec/models/form/lettings/pages/rent_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::RentType, type: :model do +RSpec.describe Form::Lettings::Pages::RentType, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/scheme_spec.rb b/spec/models/form/lettings/pages/scheme_spec.rb similarity index 91% rename from spec/models/form/setup/pages/scheme_spec.rb rename to spec/models/form/lettings/pages/scheme_spec.rb index 7c3566009..d369caf72 100644 --- a/spec/models/form/setup/pages/scheme_spec.rb +++ b/spec/models/form/lettings/pages/scheme_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::Scheme, type: :model do +RSpec.describe Form::Lettings::Pages::Scheme, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/tenancy_start_date_spec.rb b/spec/models/form/lettings/pages/tenancy_start_date_spec.rb similarity index 91% rename from spec/models/form/setup/pages/tenancy_start_date_spec.rb rename to spec/models/form/lettings/pages/tenancy_start_date_spec.rb index 546038287..99597e428 100644 --- a/spec/models/form/setup/pages/tenancy_start_date_spec.rb +++ b/spec/models/form/lettings/pages/tenancy_start_date_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::TenancyStartDate, type: :model do +RSpec.describe Form::Lettings::Pages::TenancyStartDate, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/pages/tenant_code_spec.rb b/spec/models/form/lettings/pages/tenant_code_spec.rb similarity index 91% rename from spec/models/form/setup/pages/tenant_code_spec.rb rename to spec/models/form/lettings/pages/tenant_code_spec.rb index dea2eb73d..e91303bc3 100644 --- a/spec/models/form/setup/pages/tenant_code_spec.rb +++ b/spec/models/form/lettings/pages/tenant_code_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Pages::TenantCode, type: :model do +RSpec.describe Form::Lettings::Pages::TenantCode, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/setup/questions/irproduct_other_spec.rb b/spec/models/form/lettings/questions/irproduct_other_spec.rb similarity index 91% rename from spec/models/form/setup/questions/irproduct_other_spec.rb rename to spec/models/form/lettings/questions/irproduct_other_spec.rb index 1d3d9ef3d..45182104a 100644 --- a/spec/models/form/setup/questions/irproduct_other_spec.rb +++ b/spec/models/form/lettings/questions/irproduct_other_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::IrproductOther, type: :model do +RSpec.describe Form::Lettings::Questions::IrproductOther, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/location_id_spec.rb b/spec/models/form/lettings/questions/location_id_spec.rb similarity index 97% rename from spec/models/form/setup/questions/location_id_spec.rb rename to spec/models/form/lettings/questions/location_id_spec.rb index 90822b41c..ce723ce38 100644 --- a/spec/models/form/setup/questions/location_id_spec.rb +++ b/spec/models/form/lettings/questions/location_id_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::LocationId, type: :model do +RSpec.describe Form::Lettings::Questions::LocationId, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/needs_type_spec.rb b/spec/models/form/lettings/questions/needs_type_spec.rb similarity index 93% rename from spec/models/form/setup/questions/needs_type_spec.rb rename to spec/models/form/lettings/questions/needs_type_spec.rb index c10fcb3b1..343a10ffd 100644 --- a/spec/models/form/setup/questions/needs_type_spec.rb +++ b/spec/models/form/lettings/questions/needs_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::NeedsType, type: :model do +RSpec.describe Form::Lettings::Questions::NeedsType, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/property_reference_spec.rb b/spec/models/form/lettings/questions/property_reference_spec.rb similarity index 93% rename from spec/models/form/setup/questions/property_reference_spec.rb rename to spec/models/form/lettings/questions/property_reference_spec.rb index 6e9f8b087..82f60c421 100644 --- a/spec/models/form/setup/questions/property_reference_spec.rb +++ b/spec/models/form/lettings/questions/property_reference_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::PropertyReference, type: :model do +RSpec.describe Form::Lettings::Questions::PropertyReference, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/renewal_spec.rb b/spec/models/form/lettings/questions/renewal_spec.rb similarity index 93% rename from spec/models/form/setup/questions/renewal_spec.rb rename to spec/models/form/lettings/questions/renewal_spec.rb index 5ecb5daef..961d65153 100644 --- a/spec/models/form/setup/questions/renewal_spec.rb +++ b/spec/models/form/lettings/questions/renewal_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::Renewal, type: :model do +RSpec.describe Form::Lettings::Questions::Renewal, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/rent_type_spec.rb b/spec/models/form/lettings/questions/rent_type_spec.rb similarity index 95% rename from spec/models/form/setup/questions/rent_type_spec.rb rename to spec/models/form/lettings/questions/rent_type_spec.rb index e52a89627..45906ec81 100644 --- a/spec/models/form/setup/questions/rent_type_spec.rb +++ b/spec/models/form/lettings/questions/rent_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::RentType, type: :model do +RSpec.describe Form::Lettings::Questions::RentType, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/scheme_id_spec.rb b/spec/models/form/lettings/questions/scheme_id_spec.rb similarity index 98% rename from spec/models/form/setup/questions/scheme_id_spec.rb rename to spec/models/form/lettings/questions/scheme_id_spec.rb index 29cfa9d0c..280bca5c8 100644 --- a/spec/models/form/setup/questions/scheme_id_spec.rb +++ b/spec/models/form/lettings/questions/scheme_id_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::SchemeId, type: :model do +RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/tenancy_start_date_spec.rb b/spec/models/form/lettings/questions/tenancy_start_date_spec.rb similarity index 90% rename from spec/models/form/setup/questions/tenancy_start_date_spec.rb rename to spec/models/form/lettings/questions/tenancy_start_date_spec.rb index 8fee79422..56031ffd9 100644 --- a/spec/models/form/setup/questions/tenancy_start_date_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_start_date_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::TenancyStartDate, type: :model do +RSpec.describe Form::Lettings::Questions::TenancyStartDate, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/questions/tenant_code_spec.rb b/spec/models/form/lettings/questions/tenant_code_spec.rb similarity index 93% rename from spec/models/form/setup/questions/tenant_code_spec.rb rename to spec/models/form/lettings/questions/tenant_code_spec.rb index 7a38f230f..a60383119 100644 --- a/spec/models/form/setup/questions/tenant_code_spec.rb +++ b/spec/models/form/lettings/questions/tenant_code_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Questions::TenantCode, type: :model do +RSpec.describe Form::Lettings::Questions::TenantCode, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/sales/setup/sections/setup_spec.rb b/spec/models/form/lettings/sections/setup_spec.rb similarity index 90% rename from spec/models/form/sales/setup/sections/setup_spec.rb rename to spec/models/form/lettings/sections/setup_spec.rb index 7bfab8cd1..6db166bd6 100644 --- a/spec/models/form/sales/setup/sections/setup_spec.rb +++ b/spec/models/form/lettings/sections/setup_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Sections::Setup, type: :model do +RSpec.describe Form::Lettings::Sections::Setup, type: :model do subject(:setup) { described_class.new(section_id, section_definition, form) } let(:section_id) { nil } diff --git a/spec/models/form/setup/subsections/setup_spec.rb b/spec/models/form/lettings/subsections/setup_spec.rb similarity index 84% rename from spec/models/form/setup/subsections/setup_spec.rb rename to spec/models/form/lettings/subsections/setup_spec.rb index 08744eadc..3e2fba32f 100644 --- a/spec/models/form/setup/subsections/setup_spec.rb +++ b/spec/models/form/lettings/subsections/setup_spec.rb @@ -1,11 +1,11 @@ require "rails_helper" -RSpec.describe Form::Setup::Subsections::Setup, type: :model do +RSpec.describe Form::Lettings::Subsections::Setup, type: :model do subject(:setup) { described_class.new(subsection_id, subsection_definition, section) } let(:subsection_id) { nil } let(:subsection_definition) { nil } - let(:section) { instance_double(Form::Setup::Sections::Setup) } + let(:section) { instance_double(Form::Lettings::Sections::Setup) } it "has correct section" do expect(setup.section).to eq(section) diff --git a/spec/models/form/sales/setup/pages/purchaser_code_spec.rb b/spec/models/form/sales/pages/purchaser_code_spec.rb similarity index 89% rename from spec/models/form/sales/setup/pages/purchaser_code_spec.rb rename to spec/models/form/sales/pages/purchaser_code_spec.rb index 7135e822b..05ee6becc 100644 --- a/spec/models/form/sales/setup/pages/purchaser_code_spec.rb +++ b/spec/models/form/sales/pages/purchaser_code_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Pages::PurchaserCode, type: :model do +RSpec.describe Form::Sales::Pages::PurchaserCode, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/sales/setup/pages/sale_date_spec.rb b/spec/models/form/sales/pages/sale_date_spec.rb similarity index 90% rename from spec/models/form/sales/setup/pages/sale_date_spec.rb rename to spec/models/form/sales/pages/sale_date_spec.rb index 56f6a6953..1b2a8a924 100644 --- a/spec/models/form/sales/setup/pages/sale_date_spec.rb +++ b/spec/models/form/sales/pages/sale_date_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Pages::SaleDate, type: :model do +RSpec.describe Form::Sales::Pages::SaleDate, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } diff --git a/spec/models/form/sales/setup/questions/purchaser_code_spec.rb b/spec/models/form/sales/questions/purchaser_code_spec.rb similarity index 91% rename from spec/models/form/sales/setup/questions/purchaser_code_spec.rb rename to spec/models/form/sales/questions/purchaser_code_spec.rb index 49ad611ba..3d01dd0ab 100644 --- a/spec/models/form/sales/setup/questions/purchaser_code_spec.rb +++ b/spec/models/form/sales/questions/purchaser_code_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Questions::PurchaserCode, type: :model do +RSpec.describe Form::Sales::Questions::PurchaserCode, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/sales/setup/questions/sale_date_spec.rb b/spec/models/form/sales/questions/sale_date_spec.rb similarity index 91% rename from spec/models/form/sales/setup/questions/sale_date_spec.rb rename to spec/models/form/sales/questions/sale_date_spec.rb index c340ea0c7..0f368abbb 100644 --- a/spec/models/form/sales/setup/questions/sale_date_spec.rb +++ b/spec/models/form/sales/questions/sale_date_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Questions::SaleDate, type: :model do +RSpec.describe Form::Sales::Questions::SaleDate, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/setup/sections/setup_spec.rb b/spec/models/form/sales/sections/setup_spec.rb similarity index 91% rename from spec/models/form/setup/sections/setup_spec.rb rename to spec/models/form/sales/sections/setup_spec.rb index 39843e1ec..f3dde50be 100644 --- a/spec/models/form/setup/sections/setup_spec.rb +++ b/spec/models/form/sales/sections/setup_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Setup::Sections::Setup, type: :model do +RSpec.describe Form::Sales::Sections::Setup, type: :model do subject(:setup) { described_class.new(section_id, section_definition, form) } let(:section_id) { nil } diff --git a/spec/models/form/sales/setup/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb similarity index 79% rename from spec/models/form/sales/setup/subsections/setup_spec.rb rename to spec/models/form/sales/subsections/setup_spec.rb index 3524d858e..61f501576 100644 --- a/spec/models/form/sales/setup/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -1,11 +1,11 @@ require "rails_helper" -RSpec.describe Form::Sales::Setup::Subsections::Setup, type: :model do +RSpec.describe Form::Sales::Subsections::Setup, type: :model do subject(:setup) { described_class.new(subsection_id, subsection_definition, section) } let(:subsection_id) { nil } let(:subsection_definition) { nil } - let(:section) { instance_double(Form::Sales::Setup::Sections::Setup) } + let(:section) { instance_double(Form::Sales::Sections::Setup) } it "has correct section" do expect(setup.section).to eq(section) diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 15db5b246..204023885 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -213,9 +213,9 @@ RSpec.describe Form, type: :model do expect(form.type).to eq("sales") expect(form.name).to eq("2022_23_sales") expect(form.setup_sections.count).to eq(1) - expect(form.setup_sections[0].class).to eq(Form::Sales::Setup::Sections::Setup) + expect(form.setup_sections[0].class).to eq(Form::Sales::Sections::Setup) expect(form.sections.count).to eq(1) - expect(form.sections[0].class).to eq(Form::Sales::Setup::Sections::Setup) + expect(form.sections[0].class).to eq(Form::Sales::Sections::Setup) expect(form.subsections.count).to eq(1) expect(form.subsections.first.id).to eq("setup") expect(form.pages.count).to eq(2)