Browse Source

[CLDC-1467] Use correct page ID

pull/911/head
Jack S 3 years ago
parent
commit
01fb4790c4
  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. 1
      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) def initialize(id, hsh, subsection)
super super
@id = "builtype" @id = "property_building_type"
@header = "" @header = ""
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@ -9,7 +9,7 @@ class Form::Sales::Pages::BuildingType < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::BuildingType.new(nil, nil, self), Form::Sales::Questions::PropertyBuildingType.new(nil, nil, self),
] ]
end end
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) def initialize(id, hsh, page)
super super
@id = "builtype" @id = "builtype"

1
app/models/form/sales/subsections/property_information.rb

@ -10,6 +10,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
] ]
end 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::BuyerLive.new(nil, nil, self),
Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::JointPurchase.new(nil, nil, self),
Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self),
Form::Sales::Pages::BuildingType.new(nil, nil, self),
] ]
end end
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"
t.integer "age2_known" t.integer "age2_known"
t.string "relat2" t.string "relat2"
t.string "otherrelat2"
t.string "sex2" t.string "sex2"
t.integer "noint" t.integer "noint"
t.integer "buy2livein" 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" 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) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil } let(:page_id) { nil }
@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::BuildingType, type: :model do
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("builtype") expect(page.id).to eq("property_building_type")
end end
it "has the correct header" do 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" 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) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } 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 it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq( 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 end

1
spec/models/form/sales/subsections/setup_spec.rb

@ -26,7 +26,6 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
buyer_live buyer_live
joint_purchase joint_purchase
number_joint_buyers number_joint_buyers
builtype
], ],
) )
end end

6
spec/models/form_spec.rb

@ -206,7 +206,7 @@ RSpec.describe Form, type: :model do
end end
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 it "creates a valid sales form" do
sections = [] sections = []
form = described_class.new(nil, 2022, sections, "sales") 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.sections[0].class).to eq(Form::Sales::Sections::Setup)
expect(form.subsections.count).to eq(1) expect(form.subsections.count).to eq(1)
expect(form.subsections.first.id).to eq("setup") 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.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.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01")) expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.end_date).to eq(Time.zone.parse("2023-07-01")) expect(form.end_date).to eq(Time.zone.parse("2023-07-01"))

Loading…
Cancel
Save