Browse Source

CLDC-1450 Update declaration question (#1098)

* Display the correct error for privacy notice and display the partial guidance at the top by default

* Always display privacy notice question

* Disable the rest of the housing characteristics questions until privacynotice is answered

* fix tests

* remove duplicate field

* Display the household questions if the buyers were not interviewed
pull/1253/head^2
kosiakkatrina 2 years ago committed by GitHub
parent
commit
9518cadcb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/models/form/question.rb
  2. 8
      app/models/form/sales/pages/age1.rb
  3. 13
      app/models/form/sales/pages/age2.rb
  4. 8
      app/models/form/sales/pages/buyer1_ethnic_group.rb
  5. 8
      app/models/form/sales/pages/buyer1_live_in_property.rb
  6. 8
      app/models/form/sales/pages/buyer1_working_situation.rb
  7. 13
      app/models/form/sales/pages/buyer2_live_in_property.rb
  8. 13
      app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
  9. 13
      app/models/form/sales/pages/buyer2_working_situation.rb
  10. 8
      app/models/form/sales/pages/gender_identity1.rb
  11. 13
      app/models/form/sales/pages/gender_identity2.rb
  12. 8
      app/models/form/sales/pages/nationality1.rb
  13. 8
      app/models/form/sales/pages/number_of_others_in_property.rb
  14. 1
      app/models/form/sales/questions/privacy_notice.rb
  15. 3
      config/locales/en.yml
  16. 2
      spec/models/form/sales/pages/age1_spec.rb
  17. 13
      spec/models/form/sales/pages/age2_spec.rb
  18. 2
      spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
  19. 2
      spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
  20. 11
      spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
  21. 11
      spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
  22. 11
      spec/models/form/sales/pages/buyer2_working_situation_spec.rb
  23. 2
      spec/models/form/sales/pages/gender_identity1_spec.rb
  24. 13
      spec/models/form/sales/pages/gender_identity2_spec.rb
  25. 2
      spec/models/form/sales/pages/nationality1_spec.rb
  26. 4
      spec/models/form/sales/questions/privacy_notice_spec.rb

3
app/models/form/question.rb

@ -14,11 +14,11 @@ class Form::Question
def initialize(id, hsh, page)
@id = id
@page = page
@guidance_position = GuidancePosition::TOP
if hsh
@check_answer_label = hsh["check_answer_label"]
@header = hsh["header"]
@guidance_partial = hsh["guidance_partial"]
@guidance_position = GuidancePosition::TOP
@hint_text = hsh["hint_text"]
@type = hsh["type"]
@min = hsh["min"]
@ -206,6 +206,7 @@ class Form::Question
def unanswered_error_message
return I18n.t("validations.declaration.missing") if id == "declaration"
return I18n.t("validations.privacynotice.missing") if id == "privacynotice"
I18n.t("validations.not_answered", question: display_label.downcase)
end

8
app/models/form/sales/pages/age1.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::Age1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_age"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

13
app/models/form/sales/pages/age2.rb

@ -2,9 +2,16 @@ class Form::Sales::Pages::Age2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_age"
@depends_on = [{
"jointpur" => 1,
}]
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/buyer1_ethnic_group.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1EthnicGroup < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_group"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/buyer1_live_in_property.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1LiveInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_live_in_property"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/buyer1_working_situation.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_working_situation"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

13
app/models/form/sales/pages/buyer2_live_in_property.rb

@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_live_in_property"
@depends_on = [{
"jointpur" => 1,
}]
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
]
end
def questions

13
app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb

@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
@depends_on = [{
"jointpur" => 1,
}]
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
]
end
def questions

13
app/models/form/sales/pages/buyer2_working_situation.rb

@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_working_situation"
@depends_on = [{
"jointpur" => 1,
}]
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/gender_identity1.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::GenderIdentity1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_gender_identity"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

13
app/models/form/sales/pages/gender_identity2.rb

@ -2,9 +2,16 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_gender_identity"
@depends_on = [{
"jointpur" => 1,
}]
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/nationality1.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::Nationality1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_nationality"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

8
app/models/form/sales/pages/number_of_others_in_property.rb

@ -2,6 +2,14 @@ class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "number_of_others_in_property"
@depends_on = [
{
"privacynotice" => 1,
},
{
"noint" => 1,
},
]
end
def questions

1
app/models/form/sales/questions/privacy_notice.rb

@ -6,7 +6,6 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
@header = "Declaration"
@type = "checkbox"
@answer_options = ANSWER_OPTIONS
@guidance_position = GuidancePosition::TOP
@guidance_partial = "privacy_notice_buyer"
end

3
config/locales/en.yml

@ -389,6 +389,9 @@ en:
declaration:
missing: "You must show the DLUHC privacy notice to the tenant before you can submit this log."
privacynotice:
missing: "You must show the DLUHC privacy notice to the buyer before you can submit this log."
scheme:
toggle_date:

2
spec/models/form/sales/pages/age1_spec.rb

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Age1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
end
end

13
spec/models/form/sales/pages/age2_spec.rb

@ -28,8 +28,15 @@ RSpec.describe Form::Sales::Pages::Age2, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"jointpur" => 1,
}])
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
])
end
end

2
spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
end
end

2
spec/models/form/sales/pages/buyer1_live_in_property_spec.rb

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
end
end

11
spec/models/form/sales/pages/buyer2_live_in_property_spec.rb

@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
])
end
end

11
spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb

@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
])
end
end

11
spec/models/form/sales/pages/buyer2_working_situation_spec.rb

@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
])
end
end

2
spec/models/form/sales/pages/gender_identity1_spec.rb

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::GenderIdentity1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
end
end

13
spec/models/form/sales/pages/gender_identity2_spec.rb

@ -28,8 +28,15 @@ RSpec.describe Form::Sales::Pages::GenderIdentity2, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"jointpur" => 1,
}])
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
},
{
"jointpur" => 1,
"noint" => 1,
},
])
end
end

2
spec/models/form/sales/pages/nationality1_spec.rb

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
end
end

4
spec/models/form/sales/questions/privacy_notice_spec.rb

@ -40,4 +40,8 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
"privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" },
})
end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the buyer before you can submit this log.")
end
end

Loading…
Cancel
Save