Browse Source

feat: fix uprn hidden in check answers

pull/1538/head
natdeanlewissoftwire 3 years ago
parent
commit
2946e5cbf3
  1. 13
      app/models/form/lettings/questions/uprn_known.rb
  2. 7
      app/models/form/sales/questions/uprn_known.rb
  3. 16
      spec/models/form/lettings/questions/uprn_known_spec.rb
  4. 16
      spec/models/form/sales/questions/uprn_known_spec.rb

13
app/models/form/lettings/questions/uprn_known.rb

@ -9,7 +9,18 @@ class Form::Lettings::Questions::UprnKnown < ::Form::Question
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br> @hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br>
You can continue without the UPRN, but it means we will need you to enter the address of the property." You can continue without the UPRN, but it means we will need you to enter the address of the property."
@conditional_for = { "uprn" => [1] } @conditional_for = { "uprn" => [1] }
@hidden_in_check_answers = true @inferred_check_answers_value = [
{
"condition" => { "uprn_known" => 0 },
"value" => "Not known",
},
]
@hidden_in_check_answers = {
"depends_on" => [
{ "uprn_known" => 0 },
{ "uprn_known" => 1 },
],
}
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {

7
app/models/form/sales/questions/uprn_known.rb

@ -15,7 +15,12 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question
"value" => "Not known", "value" => "Not known",
}, },
] ]
@hidden_in_check_answers = true @hidden_in_check_answers = {
"depends_on" => [
{ "uprn_known" => 0 },
{ "uprn_known" => 1 },
],
}
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {

16
spec/models/form/lettings/questions/uprn_known_spec.rb

@ -54,6 +54,20 @@ RSpec.describe Form::Lettings::Questions::UprnKnown, type: :model do
end end
it "has the correct hidden_in_check_answers" do it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(true) expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{ "uprn_known" => 0 },
{ "uprn_known" => 1 },
],
})
end
it "has the correct inferred_check_answers_value" do
expect(question.hidden_in_check_answers).to eq([
{
"condition" => { "uprn_known" => 0 },
"value" => "Not known",
},
])
end end
end end

16
spec/models/form/sales/questions/uprn_known_spec.rb

@ -54,6 +54,20 @@ RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
end end
it "has the correct hidden_in_check_answers" do it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(true) expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{ "uprn_known" => 0 },
{ "uprn_known" => 1 },
],
})
end
it "has the correct inferred_check_answers_value" do
expect(question.hidden_in_check_answers).to eq([
{
"condition" => { "uprn_known" => 0 },
"value" => "Not known",
},
])
end end
end end

Loading…
Cancel
Save