Browse Source

Don't explicitly hide la and property information questions from CYA (#1510)

pull/1511/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
54476a5c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      app/models/form/lettings/questions/address_line1.rb
  2. 4
      app/models/form/lettings/questions/la.rb
  3. 30
      spec/models/form/lettings/questions/la_spec.rb

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

@ -9,15 +9,6 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
@check_answer_label = "Q12 - Address"
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)
[
log.address_line1,

4
app/models/form/lettings/questions/la.rb

@ -13,8 +13,4 @@ class Form::Lettings::Questions::La < ::Form::Question
def answer_options
{ "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).england.map { |la| [la.code, la.name] }.to_h)
end
def hidden_in_check_answers?(log, _current_user = nil)
log.startdate && log.startdate.year >= 2023 && log.is_la_inferred?
end
end

30
spec/models/form/lettings/questions/la_spec.rb

@ -310,34 +310,4 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E06000065" => "North Yorkshire",
})
end
describe "has the correct hidden_in_check_answers" do
context "when saledate.year before 2023" do
let(:log) { build(:lettings_log, startdate: Time.zone.parse("2022-07-01")) }
it "returns false" do
expect(question.hidden_in_check_answers?(log)).to eq(false)
end
end
context "when saledate.year >= 2023" do
let(:log) { build(:lettings_log, startdate: Time.zone.parse("2023-07-01")) }
it "returns true" do
expect(question.hidden_in_check_answers?(log)).to eq(false)
end
end
context "when saledate.year >= 2023 and la inferred" do
let(:log) { build(:lettings_log, startdate: Time.zone.parse("2023-07-01")) }
before do
allow(log).to receive(:is_la_inferred?).and_return(true)
end
it "returns true" do
expect(question.hidden_in_check_answers?(log)).to eq(true)
end
end
end
end

Loading…
Cancel
Save