From c52a30ae0c8cf335965340a1c03915d8068ee2a6 Mon Sep 17 00:00:00 2001 From: Ted-U <92022120+Ted-U@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:39:05 +0100 Subject: [PATCH] [CLDC-1467] add type of building question to sales (#911) * add type of building question to sales * update check answer label * fix tests * [CLDC-1467] Use correct page ID Co-authored-by: Jack S --- ...building_type.rb => property_building_type.rb} | 6 +++--- ...building_type.rb => property_building_type.rb} | 2 +- .../sales/subsections/property_information.rb | 1 + app/models/form/sales/subsections/setup.rb | 1 - db/schema.rb | 1 + ...ype_spec.rb => property_building_type_spec.rb} | 4 ++-- ...ype_spec.rb => property_building_type_spec.rb} | 2 +- .../subsections/property_information_spec.rb | 6 +++++- spec/models/form/sales/subsections/setup_spec.rb | 15 ++++++++++++++- spec/models/form_spec.rb | 6 +++--- 10 files changed, 31 insertions(+), 13 deletions(-) rename app/models/form/sales/pages/{building_type.rb => property_building_type.rb} (51%) rename app/models/form/sales/questions/{building_type.rb => property_building_type.rb} (86%) rename spec/models/form/sales/pages/{building_type_spec.rb => property_building_type_spec.rb} (82%) rename spec/models/form/sales/questions/{building_type_spec.rb => property_building_type_spec.rb} (93%) diff --git a/app/models/form/sales/pages/building_type.rb b/app/models/form/sales/pages/property_building_type.rb similarity index 51% rename from app/models/form/sales/pages/building_type.rb rename to app/models/form/sales/pages/property_building_type.rb index f37319ee1..8f93b305c 100644 --- a/app/models/form/sales/pages/building_type.rb +++ b/app/models/form/sales/pages/property_building_type.rb @@ -1,7 +1,7 @@ -class Form::Sales::Pages::BuildingType < ::Form::Page +class Form::Sales::Pages::PropertyBuildingType < ::Form::Page def initialize(id, hsh, subsection) super - @id = "builtype" + @id = "property_building_type" @header = "" @description = "" @subsection = subsection @@ -9,7 +9,7 @@ class Form::Sales::Pages::BuildingType < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::BuildingType.new(nil, nil, self), + Form::Sales::Questions::PropertyBuildingType.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/questions/building_type.rb b/app/models/form/sales/questions/property_building_type.rb similarity index 86% rename from app/models/form/sales/questions/building_type.rb rename to app/models/form/sales/questions/property_building_type.rb index 6673d5a6d..416c9928e 100644 --- a/app/models/form/sales/questions/building_type.rb +++ b/app/models/form/sales/questions/property_building_type.rb @@ -1,4 +1,4 @@ -class Form::Sales::Questions::BuildingType < ::Form::Question +class Form::Sales::Questions::PropertyBuildingType < ::Form::Question def initialize(id, hsh, page) super @id = "builtype" diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 6a0287de4..61791cb79 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -10,6 +10,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), + Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), ] end diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index b9ba89dcf..f39926db3 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -20,7 +20,6 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection Form::Sales::Pages::BuyerLive.new(nil, nil, self), Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), - Form::Sales::Pages::BuildingType.new(nil, nil, self), ] end end diff --git a/db/schema.rb b/db/schema.rb index 7e6c34a26..eec74a385 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -348,6 +348,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do t.integer "age2" t.integer "age2_known" t.string "relat2" + t.string "otherrelat2" t.string "sex2" t.integer "noint" t.integer "buy2livein" diff --git a/spec/models/form/sales/pages/building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb similarity index 82% rename from spec/models/form/sales/pages/building_type_spec.rb rename to spec/models/form/sales/pages/property_building_type_spec.rb index 03824cb4e..fb5420105 100644 --- a/spec/models/form/sales/pages/building_type_spec.rb +++ b/spec/models/form/sales/pages/property_building_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::BuildingType, type: :model do +RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::BuildingType, type: :model do end it "has the correct id" do - expect(page.id).to eq("builtype") + expect(page.id).to eq("property_building_type") end it "has the correct header" do diff --git a/spec/models/form/sales/questions/building_type_spec.rb b/spec/models/form/sales/questions/property_building_type_spec.rb similarity index 93% rename from spec/models/form/sales/questions/building_type_spec.rb rename to spec/models/form/sales/questions/property_building_type_spec.rb index bc81ccda0..1129bf792 100644 --- a/spec/models/form/sales/questions/building_type_spec.rb +++ b/spec/models/form/sales/questions/property_building_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Questions::BuildingType, type: :model do +RSpec.describe Form::Sales::Questions::PropertyBuildingType, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index 76985d7c0..ab33936c5 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -13,7 +13,11 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do it "has correct pages" do expect(property_information.pages.map(&:id)).to eq( - %w[property_number_of_bedrooms property_unit_type], + %w[ + property_number_of_bedrooms + property_building_type + property_unit_type + ], ) end diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index ec7ff4ada..36fbf247a 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -13,7 +13,20 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do it "has correct pages" do expect(setup.pages.map(&:id)).to eq( - %w[organisation created_by completion_date purchaser_code ownership_scheme shared_ownership_type discounted_ownership_type outright_ownership_type buyer_company buyer_live joint_purchase number_joint_buyers builtype], + %w[ + organisation + created_by + completion_date + purchaser_code + ownership_scheme + shared_ownership_type + discounted_ownership_type + outright_ownership_type + buyer_company + buyer_live + joint_purchase + number_joint_buyers + ], ) end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 571e7930e..a062a4aa5 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -206,7 +206,7 @@ RSpec.describe Form, type: :model do end end - describe "when creating a sales log" do + describe "when creating a sales log", :aggregate_failures do it "creates a valid sales form" do sections = [] form = described_class.new(nil, 2022, sections, "sales") @@ -218,9 +218,9 @@ RSpec.describe Form, type: :model do 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(13) + expect(form.pages.count).to eq(12) expect(form.pages.first.id).to eq("organisation") - expect(form.questions.count).to eq(14) + expect(form.questions.count).to eq(13) expect(form.questions.first.id).to eq("owning_organisation_id") expect(form.start_date).to eq(Time.zone.parse("2022-04-01")) expect(form.end_date).to eq(Time.zone.parse("2023-07-01"))