Browse Source

CLDC-3736: Don't route to property building type or wheelchair accessibility for staircasing sales from 2025 (#2761)

* CLDC-3736: Don't route to property building type or wheelchair accessibility for staircasing sales from 2025

* Add tests for routed_to?

* Fix test
pull/2757/head^2
Rachael Booth 2 months ago committed by GitHub
parent
commit
e2123f8b9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/form/sales/pages/property_building_type.rb
  2. 4
      app/models/form/sales/pages/property_wheelchair_accessible.rb
  3. 45
      spec/models/form/sales/pages/property_building_type_spec.rb
  4. 49
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb

4
app/models/form/sales/pages/property_building_type.rb

@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyBuildingType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_building_type"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end
def questions

4
app/models/form/sales/pages/property_wheelchair_accessible.rb

@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_wheelchair_accessible"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end
def questions

45
spec/models/form/sales/pages/property_building_type_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -22,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do
it "has the correct description" do
expect(page.description).to be_nil
end
context "with form year 2024" do
let(:form) { Form.new(nil, 2024, [], "sales") }
let(:saledate) { Time.zone.local(2024, 4, 1) }
context "with a staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
context "with a non-staircasing log" do
let(:log) { build(:sales_log, staircase: nil, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
end
context "with form year 2025" do
let(:form) { Form.new(nil, 2025, [], "sales") }
let(:saledate) { Time.zone.local(2025, 4, 1) }
context "with a staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) }
it "is not routed to" do
expect(page.routed_to?(log, nil)).to be false
end
end
context "with a non-staircasing log" do
let(:log) { build(:sales_log, staircase: nil, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
end
end

49
spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb

@ -5,11 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
end
let(:form) { instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -26,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do
it "has the correct description" do
expect(page.description).to be_nil
end
context "with form year 2024" do
let(:form) { Form.new(nil, 2024, [], "sales") }
let(:saledate) { Time.zone.local(2024, 4, 1) }
context "with a staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
context "with a non-staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
end
context "with form year 2025" do
let(:form) { Form.new(nil, 2025, [], "sales") }
let(:saledate) { Time.zone.local(2025, 4, 1) }
context "with a staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) }
it "is not routed to" do
expect(page.routed_to?(log, nil)).to be false
end
end
context "with a non-staircasing log" do
let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) }
it "is routed to" do
expect(page.routed_to?(log, nil)).to be true
end
end
end
end

Loading…
Cancel
Save