From 9518cadcb557107a3b81f69506c6a71a3f93e11e Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 31 Jan 2023 12:00:47 +0000 Subject: [PATCH] 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 --- app/models/form/question.rb | 3 ++- app/models/form/sales/pages/age1.rb | 8 ++++++++ app/models/form/sales/pages/age2.rb | 13 ++++++++++--- app/models/form/sales/pages/buyer1_ethnic_group.rb | 8 ++++++++ .../form/sales/pages/buyer1_live_in_property.rb | 8 ++++++++ .../form/sales/pages/buyer1_working_situation.rb | 8 ++++++++ .../form/sales/pages/buyer2_live_in_property.rb | 13 ++++++++++--- .../sales/pages/buyer2_relationship_to_buyer1.rb | 13 ++++++++++--- .../form/sales/pages/buyer2_working_situation.rb | 13 ++++++++++--- app/models/form/sales/pages/gender_identity1.rb | 8 ++++++++ app/models/form/sales/pages/gender_identity2.rb | 13 ++++++++++--- app/models/form/sales/pages/nationality1.rb | 8 ++++++++ .../sales/pages/number_of_others_in_property.rb | 8 ++++++++ app/models/form/sales/questions/privacy_notice.rb | 1 - config/locales/en.yml | 3 +++ spec/models/form/sales/pages/age1_spec.rb | 2 +- spec/models/form/sales/pages/age2_spec.rb | 13 ++++++++++--- .../form/sales/pages/buyer1_ethnic_group_spec.rb | 2 +- .../sales/pages/buyer1_live_in_property_spec.rb | 2 +- .../sales/pages/buyer2_live_in_property_spec.rb | 11 ++++++++++- .../pages/buyer2_relationship_to_buyer1_spec.rb | 11 ++++++++++- .../sales/pages/buyer2_working_situation_spec.rb | 11 ++++++++++- .../form/sales/pages/gender_identity1_spec.rb | 2 +- .../form/sales/pages/gender_identity2_spec.rb | 13 ++++++++++--- spec/models/form/sales/pages/nationality1_spec.rb | 2 +- .../form/sales/questions/privacy_notice_spec.rb | 4 ++++ 26 files changed, 170 insertions(+), 31 deletions(-) diff --git a/app/models/form/question.rb b/app/models/form/question.rb index cbfc6aae2..02f9f3235 100644 --- a/app/models/form/question.rb +++ b/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 diff --git a/app/models/form/sales/pages/age1.rb b/app/models/form/sales/pages/age1.rb index de9b1ef8d..5aed5c4f3 100644 --- a/app/models/form/sales/pages/age1.rb +++ b/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 diff --git a/app/models/form/sales/pages/age2.rb b/app/models/form/sales/pages/age2.rb index d849c1465..ff0666988 100644 --- a/app/models/form/sales/pages/age2.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer1_ethnic_group.rb b/app/models/form/sales/pages/buyer1_ethnic_group.rb index af0269290..73d66b328 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_group.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer1_live_in_property.rb b/app/models/form/sales/pages/buyer1_live_in_property.rb index 0d780ffed..deb6275af 100644 --- a/app/models/form/sales/pages/buyer1_live_in_property.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer1_working_situation.rb b/app/models/form/sales/pages/buyer1_working_situation.rb index 8d56caa47..66cf38e69 100644 --- a/app/models/form/sales/pages/buyer1_working_situation.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer2_live_in_property.rb b/app/models/form/sales/pages/buyer2_live_in_property.rb index 8904c21f2..9ba67080b 100644 --- a/app/models/form/sales/pages/buyer2_live_in_property.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb index 026486883..7a1612d1f 100644 --- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb +++ b/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 diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb index 4523c34cc..704fc0eac 100644 --- a/app/models/form/sales/pages/buyer2_working_situation.rb +++ b/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 diff --git a/app/models/form/sales/pages/gender_identity1.rb b/app/models/form/sales/pages/gender_identity1.rb index 2dadce8ba..a9d333cf4 100644 --- a/app/models/form/sales/pages/gender_identity1.rb +++ b/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 diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb index 3d72842c9..f79c3dc4a 100644 --- a/app/models/form/sales/pages/gender_identity2.rb +++ b/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 diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb index 65bba7c6a..96723e857 100644 --- a/app/models/form/sales/pages/nationality1.rb +++ b/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 diff --git a/app/models/form/sales/pages/number_of_others_in_property.rb b/app/models/form/sales/pages/number_of_others_in_property.rb index ed82303ec..c090422fd 100644 --- a/app/models/form/sales/pages/number_of_others_in_property.rb +++ b/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 diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index 5bc84bce6..4d7bb61c6 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 07eb15c89..a469aa737 100644 --- a/config/locales/en.yml +++ b/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: diff --git a/spec/models/form/sales/pages/age1_spec.rb b/spec/models/form/sales/pages/age1_spec.rb index 0c8130bad..6205610a0 100644 --- a/spec/models/form/sales/pages/age1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/age2_spec.rb b/spec/models/form/sales/pages/age2_spec.rb index eabb6a2e8..2645b3724 100644 --- a/spec/models/form/sales/pages/age2_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb index e6e6798f5..52bbaff53 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb index 444f14909..6bdd4f5e2 100644 --- a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb index 34644241f..258e37462 100644 --- a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb index eef011089..a518a1dc4 100644 --- a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb index fe339091b..59c16c583 100644 --- a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/gender_identity1_spec.rb b/spec/models/form/sales/pages/gender_identity1_spec.rb index 2b06f2349..5188bb4ae 100644 --- a/spec/models/form/sales/pages/gender_identity1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/gender_identity2_spec.rb b/spec/models/form/sales/pages/gender_identity2_spec.rb index 7698f151c..54e7ab565 100644 --- a/spec/models/form/sales/pages/gender_identity2_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb index c39fecdd2..da5a5f802 100644 --- a/spec/models/form/sales/pages/nationality1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index fc1df796c..1fec22b6e 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/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