diff --git a/app/models/form/lettings/pages/address_matcher.rb b/app/models/form/lettings/pages/address_matcher.rb index a48eb21c3..859e31077 100644 --- a/app/models/form/lettings/pages/address_matcher.rb +++ b/app/models/form/lettings/pages/address_matcher.rb @@ -20,4 +20,10 @@ class Form::Lettings::Pages::AddressMatcher < ::Form::Page def submit_text "Search" end + + def skip_href(log = nil) + return unless log + + "/#{log.model_name.param_key.dasherize}s/#{log.id}/property-unit-type" + end end diff --git a/app/models/form/sales/pages/address_matcher.rb b/app/models/form/sales/pages/address_matcher.rb index 033b398c8..5d2a38767 100644 --- a/app/models/form/sales/pages/address_matcher.rb +++ b/app/models/form/sales/pages/address_matcher.rb @@ -20,4 +20,10 @@ class Form::Sales::Pages::AddressMatcher < ::Form::Page def submit_text "Search" end + + def skip_href(log = nil) + return unless log + + "/#{log.model_name.param_key.dasherize}s/#{log.id}/property-number-of-bedrooms" + end end diff --git a/spec/models/form/lettings/pages/address_matcher_spec.rb b/spec/models/form/lettings/pages/address_matcher_spec.rb index 284e18825..8cc98f480 100644 --- a/spec/models/form/lettings/pages/address_matcher_spec.rb +++ b/spec/models/form/lettings/pages/address_matcher_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Form::Lettings::Pages::AddressMatcher, type: :model do let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:log) { create(:lettings_log) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -30,4 +31,10 @@ RSpec.describe Form::Lettings::Pages::AddressMatcher, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq([{ "is_supported_housing?" => false, "uprn_known" => nil }, { "is_supported_housing?" => false, "uprn_known" => 0 }, { "is_supported_housing?" => false, "uprn_confirmed" => 0 }]) end + + it "has the correct skip_href" do + expect(page.skip_href(log)).to eq( + "/lettings-logs/#{log.id}/property-unit-type", + ) + end end diff --git a/spec/models/form/sales/pages/address_matcher_spec.rb b/spec/models/form/sales/pages/address_matcher_spec.rb index bcbfed6c5..e2eea6fa0 100644 --- a/spec/models/form/sales/pages/address_matcher_spec.rb +++ b/spec/models/form/sales/pages/address_matcher_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Form::Sales::Pages::AddressMatcher, type: :model do let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:log) { create(:sales_log) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -30,4 +31,10 @@ RSpec.describe Form::Sales::Pages::AddressMatcher, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq([{ "uprn_known" => nil }, { "uprn_known" => 0 }, { "uprn_confirmed" => 0 }]) end + + it "has the correct skip_href" do + expect(page.skip_href(log)).to eq( + "/sales-logs/#{log.id}/property-number-of-bedrooms", + ) + end end