From 99ad80aebde418f2be6de9e35f3867b9d60e18d1 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:48:22 +0000 Subject: [PATCH] feat: update skip links (#2342) --- app/models/form/lettings/pages/address_matcher.rb | 6 ++++++ app/models/form/sales/pages/address_matcher.rb | 6 ++++++ spec/models/form/lettings/pages/address_matcher_spec.rb | 7 +++++++ spec/models/form/sales/pages/address_matcher_spec.rb | 7 +++++++ 4 files changed, 26 insertions(+) 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