diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb new file mode 100644 index 000000000..a7e8ca219 --- /dev/null +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::PrivacyNotice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "privacy_notice" + @header = "Department for Levelling Up, Housing and Communities privacy notice" + @description = "" + @subsection = subsection + @depends_on = [{ + "noint" => 1, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::PrivacyNotice.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb new file mode 100644 index 000000000..e853b38de --- /dev/null +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::PrivacyNotice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "privacynotice" + @check_answer_label = "Buyer has seen the privacy notice?" + @header = "Declaration" + @type = "checkbox" + @hint_text = "" + @page = page + @answer_options = ANSWER_OPTIONS + @guidance_position = GuidancePosition::TOP + @guidance_partial = "privacy_notice_buyer" + end + + ANSWER_OPTIONS = { + "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, + }.freeze +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index e389d5e72..055aca08b 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -10,6 +10,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::BuyerInterview.new(nil, nil, self), + Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), diff --git a/app/views/form/guidance/_privacy_notice_buyer.erb b/app/views/form/guidance/_privacy_notice_buyer.erb new file mode 100644 index 000000000..fabe9ced1 --- /dev/null +++ b/app/views/form/guidance/_privacy_notice_buyer.erb @@ -0,0 +1 @@ +

Make sure the buyer has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

diff --git a/app/views/form/guidance/_privacy_notice.erb b/app/views/form/guidance/_privacy_notice_tenant.erb similarity index 57% rename from app/views/form/guidance/_privacy_notice.erb rename to app/views/form/guidance/_privacy_notice_tenant.erb index c6e0b9adc..88b281730 100644 --- a/app/views/form/guidance/_privacy_notice.erb +++ b/app/views/form/guidance/_privacy_notice_tenant.erb @@ -1 +1 @@ -

Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path %> before completing this log.

+

Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 4292d1d3a..801ab5717 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1143,7 +1143,7 @@ "questions": { "declaration": { "header": "", - "guidance_partial": "privacy_notice", + "guidance_partial": "privacy_notice_tenant", "check_answer_label": "Tenant has seen the privacy notice", "check_answers_card_number": 0, "type": "checkbox", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index b30461a84..490d28e12 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -1178,7 +1178,7 @@ "questions": { "declaration": { "header": "", - "guidance_partial": "privacy_notice", + "guidance_partial": "privacy_notice_tenant", "check_answer_label": "Tenant has seen the privacy notice", "check_answers_card_number": 0, "type": "checkbox", diff --git a/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb new file mode 100644 index 000000000..f60b00823 --- /dev/null +++ b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddPrivacyNoticeToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :privacynotice, :int + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 269091a77..368f1a4e8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -329,17 +329,19 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do t.string "purchid" t.integer "type" t.integer "ownershipsch" - t.integer "jointpur" t.string "othtype" - t.integer "beds" t.integer "jointmore" + t.integer "jointpur" + t.integer "beds" + t.integer "companybuy" t.integer "age1" t.integer "age1_known" t.string "sex1" t.integer "national" t.string "othernational" + t.integer "ethnic" + t.integer "ethnic_group" t.integer "buy1livein" - t.integer "companybuy" t.integer "buylivein" t.integer "builtype" t.integer "proptype" @@ -347,12 +349,11 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do t.integer "age2_known" t.string "relat2" t.string "otherrelat2" - t.integer "ethnic" - t.integer "ethnic_group" t.string "sex2" t.integer "noint" t.integer "buy2livein" t.integer "ecstat2" + t.integer "privacynotice" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb new file mode 100644 index 000000000..9c957b0b5 --- /dev/null +++ b/spec/models/form/sales/pages/privacy_notice_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { nil } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[privacynotice]) + end + + it "has the correct id" do + expect(page.id).to eq("privacy_notice") + end + + it "has the correct header" do + expect(page.header).to eq("Department for Levelling Up, Housing and Communities privacy notice") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "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 new file mode 100644 index 000000000..f90daef1b --- /dev/null +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -0,0 +1,43 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("privacynotice") + end + + it "has the correct header" do + expect(question.header).to eq("Declaration") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer has seen the privacy notice?") + end + + it "has the correct type" do + expect(question.type).to eq("checkbox") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, + }) + end +end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 21e496efd..29874c8e6 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model expect(household_characteristics.pages.map(&:id)).to eq( %w[ buyer_interview + privacy_notice buyer_1_age buyer_1_gender_identity buyer_1_ethnic_group diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 32b6fbc7d..c42b021cd 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -61,14 +61,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(31) + expect(form.pages.count).to eq(32) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(31) + expect(form.pages.count).to eq(32) expect(form.name).to eq("2021_2022_sales") end end