Browse Source

CLDC-2217 Skip inferred LA question (#1496)

* Display address question if it's routed to

* Remove routed to from the la questions
pull/1500/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
02d7058cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/models/form/lettings/pages/property_local_authority.rb
  2. 6
      app/models/form/sales/pages/property_local_authority.rb
  3. 9
      app/models/form/sales/questions/address_line1.rb
  4. 39
      spec/models/form/lettings/pages/property_local_authority_spec.rb
  5. 29
      spec/models/form/sales/pages/property_local_authority_spec.rb

8
app/models/form/lettings/pages/property_local_authority.rb

@ -8,12 +8,4 @@ class Form::Lettings::Pages::PropertyLocalAuthority < ::Form::Page
def questions def questions
@questions ||= [Form::Lettings::Questions::La.new(nil, nil, self)] @questions ||= [Form::Lettings::Questions::La.new(nil, nil, self)]
end end
def routed_to?(log, _current_user = nil)
return false if log.uprn_known.nil? && form.start_date.year >= 2023
return false if log.is_la_inferred?
return false if log.is_supported_housing?
true
end
end end

6
app/models/form/sales/pages/property_local_authority.rb

@ -14,12 +14,6 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page
].compact ].compact
end end
def routed_to?(log, _current_user = nil)
return false if log.uprn_known.nil? && form.start_date.year >= 2023
true
end
def la_known_question def la_known_question
if form.start_date.year < 2023 if form.start_date.year < 2023
Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self) Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self)

9
app/models/form/sales/questions/address_line1.rb

@ -9,15 +9,6 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
@check_answer_label = "Q15 - Address" @check_answer_label = "Q15 - Address"
end end
def hidden_in_check_answers?(log, _current_user = nil)
return true if log.uprn_known.nil?
return false if log.uprn_known&.zero?
return true if log.uprn_confirmed.nil? && log.uprn.present?
return true if log.uprn_known == 1 && log.uprn.blank?
log.uprn_confirmed == 1
end
def answer_label(log, _current_user = nil) def answer_label(log, _current_user = nil)
[ [
log.address_line1, log.address_line1,

39
spec/models/form/lettings/pages/property_local_authority_spec.rb

@ -35,43 +35,4 @@ RSpec.describe Form::Lettings::Pages::PropertyLocalAuthority, type: :model do
it "has the correct depends_on" do it "has the correct depends_on" do
expect(page.depends_on).to match([{ "is_general_needs?" => true, "is_la_inferred" => false }]) expect(page.depends_on).to match([{ "is_general_needs?" => true, "is_la_inferred" => false }])
end end
describe "has correct routed_to?" do
context "when start_date < 2023" do
let(:log) { create(:lettings_log, uprn_known: 1) }
let(:start_date) { Time.utc(2022, 2, 8) }
it "returns false" do
expect(page.routed_to?(log)).to eq(true)
end
end
context "when start_date >= 2023" do
let(:log) { create(:lettings_log, uprn_known: 1) }
let(:start_date) { Time.utc(2023, 2, 8) }
it "returns true" do
expect(page.routed_to?(log)).to eq(true)
end
end
context "when start_date < 2023 and uprn_known: nil" do
let(:log) { create(:lettings_log, uprn_known: nil) }
let(:start_date) { Time.utc(2023, 2, 8) }
it "returns true" do
expect(page.routed_to?(log)).to eq(false)
end
context "when is_la_inferred: true" do
before do
allow(log).to receive(:is_la_inferred?).and_return(true)
end
it "returns true" do
expect(page.routed_to?(log)).to eq(false)
end
end
end
end
end end

29
spec/models/form/sales/pages/property_local_authority_spec.rb

@ -56,33 +56,4 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
"is_la_inferred" => false, "is_la_inferred" => false,
}]) }])
end end
describe "has correct routed_to?" do
context "when start_date < 2023" do
let(:log) { create(:sales_log, uprn_known: 1) }
let(:start_date) { Time.utc(2022, 2, 8) }
it "returns false" do
expect(page.routed_to?(log)).to eq(true)
end
end
context "when start_date >= 2023" do
let(:log) { create(:sales_log, uprn_known: 1) }
let(:start_date) { Time.utc(2023, 2, 8) }
it "returns true" do
expect(page.routed_to?(log)).to eq(true)
end
end
context "when start_date < 2023 and uprn_known: nil" do
let(:log) { create(:sales_log, uprn_known: nil) }
let(:start_date) { Time.utc(2023, 2, 8) }
it "returns true" do
expect(page.routed_to?(log)).to eq(false)
end
end
end
end end

Loading…
Cancel
Save