Browse Source

[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 <jacopo.scotti@softwire.com>
pull/939/head
Ted-U 2 years ago committed by GitHub
parent
commit
c52a30ae0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/form/sales/pages/property_building_type.rb
  2. 2
      app/models/form/sales/questions/property_building_type.rb
  3. 1
      app/models/form/sales/subsections/property_information.rb
  4. 1
      app/models/form/sales/subsections/setup.rb
  5. 1
      db/schema.rb
  6. 4
      spec/models/form/sales/pages/property_building_type_spec.rb
  7. 2
      spec/models/form/sales/questions/property_building_type_spec.rb
  8. 6
      spec/models/form/sales/subsections/property_information_spec.rb
  9. 15
      spec/models/form/sales/subsections/setup_spec.rb
  10. 6
      spec/models/form_spec.rb

6
app/models/form/sales/pages/building_type.rb → 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

2
app/models/form/sales/questions/building_type.rb → 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"

1
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

1
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

1
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"

4
spec/models/form/sales/pages/building_type_spec.rb → 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

2
spec/models/form/sales/questions/building_type_spec.rb → 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 }

6
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

15
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

6
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"))

Loading…
Cancel
Save