From 98a10cc3aeaefb10044f416e03308de7fa79b6dc Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 16 Dec 2022 11:39:39 +0000 Subject: [PATCH] Display the correct error for privacy notice and display the partial guidance at the top by default --- app/models/form/question.rb | 3 ++- app/models/form/sales/questions/privacy_notice.rb | 1 - config/locales/en.yml | 3 +++ spec/models/form/sales/questions/privacy_notice_spec.rb | 4 ++++ 4 files changed, 9 insertions(+), 2 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/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 445dfc09f..0af418907 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -383,6 +383,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/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