Browse Source

CLDC-3309: Update privacy notice/declaration error message for 2024 (#2315)

* CLDC-3309: Update privacy notice/declaration error message for 2024

* Remove missing answer feature test

* Remove unused definition
pull/2318/head
Rachael Booth 9 months ago committed by GitHub
parent
commit
5937ae3328
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      app/models/form/lettings/questions/declaration.rb
  2. 3
      app/models/form/question.rb
  3. 9
      app/models/form/sales/questions/privacy_notice.rb
  4. 8
      config/locales/en.yml
  5. 22
      spec/features/form/validations_spec.rb
  6. 10
      spec/models/form/lettings/questions/declaration_spec.rb
  7. 76
      spec/models/form/sales/questions/privacy_notice_spec.rb

8
app/models/form/lettings/questions/declaration.rb

@ -20,5 +20,13 @@ class Form::Lettings::Questions::Declaration < ::Form::Question
{ "declaration" => { "value" => declaration_text } }.freeze { "declaration" => { "value" => declaration_text } }.freeze
end end
def unanswered_error_message
if form.start_year_after_2024?
I18n.t("validations.declaration.missing.post_2024")
else
I18n.t("validations.declaration.missing.pre_2024")
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 30, 2024 => 11 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 30, 2024 => 11 }.freeze
end end

3
app/models/form/question.rb

@ -198,9 +198,6 @@ class Form::Question
end end
def unanswered_error_message 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: error_display_label.downcase) I18n.t("validations.not_answered", question: error_display_label.downcase)
end end

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

@ -20,6 +20,15 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
{ "privacynotice" => { "value" => declaration_text } }.freeze { "privacynotice" => { "value" => declaration_text } }.freeze
end end
def unanswered_error_message
buyer_or_buyers = @joint_purchase ? "buyers" : "buyer"
if form.start_year_after_2024?
I18n.t("validations.privacynotice.missing.post_2024", buyer_or_buyers:)
else
I18n.t("validations.privacynotice.missing.pre_2024", buyer_or_buyers:)
end
end
def guidance def guidance
if form.start_year_after_2024? if form.start_year_after_2024?
@joint_purchase ? "privacy_notice_buyer_2024_joint_purchase" : "privacy_notice_buyer_2024" @joint_purchase ? "privacy_notice_buyer_2024_joint_purchase" : "privacy_notice_buyer_2024"

8
config/locales/en.yml

@ -567,10 +567,14 @@ en:
joint_more_than_one_member: "There must be more than one person in the household as you've told us this is a joint tenancy" joint_more_than_one_member: "There must be more than one person in the household as you've told us this is a joint tenancy"
declaration: declaration:
missing: "You must show the DLUHC privacy notice to the tenant before you can submit this log." missing:
pre_2024: "You must show the DLUHC privacy notice to the tenant before you can submit this log."
post_2024: "You must show or give access to the DLUHC privacy notice to the tenant before you can submit this log."
privacynotice: privacynotice:
missing: "You must show the DLUHC privacy notice to the buyer before you can submit this log." missing:
pre_2024: "You must show the DLUHC privacy notice to the %{buyer_or_buyers} before you can submit this log."
post_2024: "You must show or give access to the DLUHC privacy notice to the %{buyer_or_buyers} before you can submit this log."
scheme: scheme:
toggle_date: toggle_date:

22
spec/features/form/validations_spec.rb

@ -27,18 +27,6 @@ RSpec.describe "validations" do
created_by: user, created_by: user,
) )
end end
let(:completed_without_declaration) do
FactoryBot.create(
:lettings_log,
:completed,
created_by: user,
status: 1,
declaration: nil,
startdate: Time.zone.local(2021, 5, 1),
voiddate: Time.zone.local(2021, 5, 1),
mrcdate: Time.zone.local(2021, 5, 1),
)
end
let(:id) { lettings_log.id } let(:id) { lettings_log.id }
before do before do
@ -199,14 +187,4 @@ RSpec.describe "validations" do
end end
end end
end end
describe "Submission validation" do
context "when tenant has not seen the privacy notice" do
it "shows a warning" do
visit("/lettings-logs/#{completed_without_declaration.id}/declaration")
click_button("Save and continue")
expect(page).to have_content("You must show the DLUHC privacy notice to the tenant")
end
end
end
end end

10
spec/models/form/lettings/questions/declaration_spec.rb

@ -61,6 +61,10 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
it "has check_answers_card_number = 0" do it "has check_answers_card_number = 0" do
expect(question.check_answers_card_number).to eq(0) expect(question.check_answers_card_number).to eq(0)
end end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the tenant before you can submit this log.")
end
end end
context "when the form year is >= 2024" do context "when the form year is >= 2024" do
@ -81,9 +85,9 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
it "has check_answers_card_number nil" do it "has check_answers_card_number nil" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the tenant before you can submit this log.") expect(question.unanswered_error_message).to eq("You must show or give access to the DLUHC privacy notice to the tenant before you can submit this log.")
end
end end
end end

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

@ -48,14 +48,38 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(false) allow(form).to receive(:start_year_after_2024?).and_return(false)
end end
it "has the correct answer_options" do context "and there is a single buyer" do
expect(question.answer_options).to eq({ it "has the correct answer_options" do
"privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, expect(question.answer_options).to eq({
}) "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" },
})
end
it "uses the expected top guidance partial" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer")
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 end
it "uses the expected top guidance partial" do context "and there are joint buyers" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer") subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyers have seen the DLUHC privacy notice" },
})
end
it "uses the expected top guidance partial" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer_joint_purchase")
end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the buyers before you can submit this log.")
end
end end
end end
@ -64,18 +88,38 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(true) allow(form).to receive(:start_year_after_2024?).and_return(true)
end end
it "has the correct answer_options" do context "and there is a single buyer" do
expect(question.answer_options).to eq({ it "has the correct answer_options" do
"privacynotice" => { "value" => "The buyer has seen or been given access to the DLUHC privacy notice" }, expect(question.answer_options).to eq({
}) "privacynotice" => { "value" => "The buyer has seen or been given access to the DLUHC privacy notice" },
end })
end
it "uses the expected top guidance partial" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024")
end
it "uses the expected top guidance partial" do it "returns correct unanswered_error_message" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024") expect(question.unanswered_error_message).to eq("You must show or give access to the DLUHC privacy notice to the buyer before you can submit this log.")
end
end end
end
it "returns correct unanswered_error_message" do context "and there are joint buyers" do
expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the buyer before you can submit this log.") subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyers have seen or been given access to the DLUHC privacy notice" },
})
end
it "uses the expected top guidance partial" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024_joint_purchase")
end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give access to the DLUHC privacy notice to the buyers before you can submit this log.")
end
end
end end
end end

Loading…
Cancel
Save