Browse Source

Cldc 1574 privacy notice (#931)

* feat: core functionality

* feat: update schema.rb

* feat: add link for privacy notice, refactor to separate tenant/buyer

* feat: make privacy notices open in new tab

* test: make previous tests pass

* test: add new tests
pull/932/head v0.2.12
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
9a0629004d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      app/models/form/sales/pages/privacy_notice.rb
  2. 18
      app/models/form/sales/questions/privacy_notice.rb
  3. 1
      app/models/form/sales/subsections/household_characteristics.rb
  4. 1
      app/views/form/guidance/_privacy_notice_buyer.erb
  5. 2
      app/views/form/guidance/_privacy_notice_tenant.erb
  6. 2
      config/forms/2021_2022.json
  7. 2
      config/forms/2022_2023.json
  8. 7
      db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb
  9. 11
      db/schema.rb
  10. 33
      spec/models/form/sales/pages/privacy_notice_spec.rb
  11. 43
      spec/models/form/sales/questions/privacy_notice_spec.rb
  12. 1
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  13. 4
      spec/models/form_handler_spec.rb

18
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

18
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

1
app/models/form/sales/subsections/household_characteristics.rb

@ -10,6 +10,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::BuyerInterview.new(nil, nil, self), 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::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self),

1
app/views/form/guidance/_privacy_notice_buyer.erb

@ -0,0 +1 @@
<p class="govuk-body">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.</p>

2
app/views/form/guidance/_privacy_notice.erb → app/views/form/guidance/_privacy_notice_tenant.erb

@ -1 +1 @@
<p class="govuk-body">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.</p> <p class="govuk-body">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.</p>

2
config/forms/2021_2022.json

@ -1143,7 +1143,7 @@
"questions": { "questions": {
"declaration": { "declaration": {
"header": "", "header": "",
"guidance_partial": "privacy_notice", "guidance_partial": "privacy_notice_tenant",
"check_answer_label": "Tenant has seen the privacy notice", "check_answer_label": "Tenant has seen the privacy notice",
"check_answers_card_number": 0, "check_answers_card_number": 0,
"type": "checkbox", "type": "checkbox",

2
config/forms/2022_2023.json

@ -1178,7 +1178,7 @@
"questions": { "questions": {
"declaration": { "declaration": {
"header": "", "header": "",
"guidance_partial": "privacy_notice", "guidance_partial": "privacy_notice_tenant",
"check_answer_label": "Tenant has seen the privacy notice", "check_answer_label": "Tenant has seen the privacy notice",
"check_answers_card_number": 0, "check_answers_card_number": 0,
"type": "checkbox", "type": "checkbox",

7
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

11
db/schema.rb

@ -329,17 +329,19 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.string "purchid" t.string "purchid"
t.integer "type" t.integer "type"
t.integer "ownershipsch" t.integer "ownershipsch"
t.integer "jointpur"
t.string "othtype" t.string "othtype"
t.integer "beds"
t.integer "jointmore" t.integer "jointmore"
t.integer "jointpur"
t.integer "beds"
t.integer "companybuy"
t.integer "age1" t.integer "age1"
t.integer "age1_known" t.integer "age1_known"
t.string "sex1" t.string "sex1"
t.integer "national" t.integer "national"
t.string "othernational" t.string "othernational"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "buy1livein" t.integer "buy1livein"
t.integer "companybuy"
t.integer "buylivein" t.integer "buylivein"
t.integer "builtype" t.integer "builtype"
t.integer "proptype" t.integer "proptype"
@ -347,12 +349,11 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.integer "age2_known" t.integer "age2_known"
t.string "relat2" t.string "relat2"
t.string "otherrelat2" t.string "otherrelat2"
t.integer "ethnic"
t.integer "ethnic_group"
t.string "sex2" t.string "sex2"
t.integer "noint" t.integer "noint"
t.integer "buy2livein" t.integer "buy2livein"
t.integer "ecstat2" t.integer "ecstat2"
t.integer "privacynotice"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" 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 ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

33
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

43
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

1
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( expect(household_characteristics.pages.map(&:id)).to eq(
%w[ %w[
buyer_interview buyer_interview
privacy_notice
buyer_1_age buyer_1_age
buyer_1_gender_identity buyer_1_gender_identity
buyer_1_ethnic_group buyer_1_ethnic_group

4
spec/models/form_handler_spec.rb

@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do it "is able to load a current sales form" do
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) 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") expect(form.name).to eq("2022_2023_sales")
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) 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") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save