Browse Source

CLDC-4402: simplify p4

CLDC-4402-audit-start-year-2024-or-later-usage-2
Rebecca Jesson 3 weeks ago
parent
commit
37769cf330
  1. 23
      app/models/form/sales/questions/buyer1_ethnic_background_white.rb
  2. 23
      app/models/form/sales/questions/buyer2_ethnic_background_white.rb
  3. 21
      app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
  4. 2
      app/models/form/sales/questions/discount.rb
  5. 7
      app/models/form/sales/questions/mortgage_lender.rb
  6. 8
      app/models/form/sales/questions/ownership_scheme.rb
  7. 21
      app/models/form/sales/questions/person_relationship_to_buyer_1.rb
  8. 12
      app/models/form/sales/questions/privacy_notice.rb
  9. 15
      app/models/form/sales/questions/uprn_confirmation.rb
  10. 2
      config/locales/en.yml
  11. 38
      spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb
  12. 38
      spec/models/form/sales/questions/buyer2_ethnic_background_white_spec.rb
  13. 6
      spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
  14. 16
      spec/models/form/sales/questions/discount_spec.rb
  15. 292
      spec/models/form/sales/questions/mortgage_lender_spec.rb
  16. 19
      spec/models/form/sales/questions/ownership_scheme_spec.rb
  17. 6
      spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb
  18. 113
      spec/models/form/sales/questions/privacy_notice_spec.rb

23
app/models/form/sales/questions/buyer1_ethnic_background_white.rb

@ -9,22 +9,13 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
}.freeze
else
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"3" => { "value" => "Any other White background" },
}.freeze
end
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
}.freeze
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 23, 2024 => 25, 2025 => 23, 2026 => 25 }.freeze

23
app/models/form/sales/questions/buyer2_ethnic_background_white.rb

@ -9,22 +9,13 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundWhite < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
}.freeze
else
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"3" => { "value" => "Any other White background" },
}.freeze
end
{
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
}.freeze
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 31, 2024 => 33, 2025 => 31, 2026 => 34 }.freeze

21
app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb

@ -16,21 +16,12 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Buyer prefers not to say" },
}
else
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." },
"X" => { "value" => "Other" },
"R" => { "value" => "Buyer prefers not to say" },
}
end
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Buyer prefers not to say" },
}
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 29, 2025 => 27, 2026 => 29 }.freeze

2
app/models/form/sales/questions/discount.rb

@ -4,7 +4,7 @@ class Form::Sales::Questions::Discount < ::Form::Question
@id = "discount"
@type = "numeric"
@min = 0
@max = form.start_year_2024_or_later? ? 70 : 100
@max = 70
@step = 0.1
@width = 5
@suffix = "%"

7
app/models/form/sales/questions/mortgage_lender.rb

@ -55,15 +55,10 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question
"0" => "Don’t know",
}.freeze
OPTIONS_INTRODUCED_2024 = %w[41].freeze
OPTIONS_NOT_DISPLAYED = %w[0].freeze
def answer_options
if form.start_year_2024_or_later?
ANSWER_OPTIONS
else
ANSWER_OPTIONS.dup.reject { |k, _v| OPTIONS_INTRODUCED_2024.include?(k) }
end
ANSWER_OPTIONS
end
def displayed_answer_options(_log, _user = nil)

8
app/models/form/sales/questions/ownership_scheme.rb

@ -12,15 +12,9 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question
"1" => { "value" => "Shared Ownership", "hint" => "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction" },
"2" => { "value" => "Discounted Ownership" },
}.freeze
elsif form.start_year_2024_or_later?
{
"1" => { "value" => "Yes - a shared ownership scheme", "hint" => "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction" },
"2" => { "value" => "Yes - a discounted ownership scheme" },
"3" => { "value" => "No - this is an outright or other sale" },
}.freeze
else
{
"1" => { "value" => "Yes - a shared ownership scheme" },
"1" => { "value" => "Yes - a shared ownership scheme", "hint" => "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction" },
"2" => { "value" => "Yes - a discounted ownership scheme" },
"3" => { "value" => "No - this is an outright or other sale" },
}.freeze

21
app/models/form/sales/questions/person_relationship_to_buyer_1.rb

@ -16,21 +16,12 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Person prefers not to say" },
}
else
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." },
"X" => { "value" => "Other" },
"R" => { "value" => "Person prefers not to say" },
}
end
{
"P" => { "value" => "Partner" },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Person prefers not to say" },
}
end
def question_number

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

@ -10,22 +10,14 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
end
def answer_options
declaration_text = if form.start_year_2024_or_later?
"The #{@joint_purchase ? 'buyers have' : 'buyer has'} seen or been given access to the MHCLG privacy notice"
else
"The #{@joint_purchase ? 'buyers have' : 'buyer has'} seen the MHCLG privacy notice"
end
declaration_text = "The #{@joint_purchase ? 'buyers have' : 'buyer has'} seen or been given access to the MHCLG privacy notice"
{ "privacynotice" => { "value" => declaration_text } }.freeze
end
def unanswered_error_message(_log = nil)
buyer_or_buyers = @joint_purchase ? "buyers" : "buyer"
if form.start_year_2024_or_later?
I18n.t("validations.privacynotice.missing.post_2024", buyer_or_buyers:)
else
I18n.t("validations.privacynotice.missing.pre_2024", buyer_or_buyers:)
end
I18n.t("validations.privacynotice.missing.post_2024", buyer_or_buyers:)
end
def guidance

15
app/models/form/sales/questions/uprn_confirmation.rb

@ -6,17 +6,10 @@ class Form::Sales::Questions::UprnConfirmation < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to search for the address instead" },
}.freeze
else
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to enter the address manually" },
}.freeze
end
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to search for the address instead" },
}.freeze
end
def notification_banner(log = nil)

2
config/locales/en.yml

@ -341,12 +341,10 @@ en:
declaration:
missing:
pre_2024: "You must show the MHCLG privacy notice to the tenant before you can submit this log."
post_2024: "You must show or give the tenant access to the MHCLG privacy notice before you can submit this log."
privacynotice:
missing:
pre_2024: "You must show the MHCLG privacy notice to the %{buyer_or_buyers} before you can submit this log."
post_2024: "You must show or give the %{buyer_or_buyers} access to the MHCLG privacy notice before you can submit this log."
scheme:

38
spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundWhite, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,31 +32,14 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundWhite, type: :model
expect(question.derived?(nil)).to be false
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"3" => { "value" => "Any other White background" },
})
end
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
})
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
})
end
it "has the correct check_answers_card_number" do

38
spec/models/form/sales/questions/buyer2_ethnic_background_white_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer2EthnicBackgroundWhite, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,30 +32,13 @@ RSpec.describe Form::Sales::Questions::Buyer2EthnicBackgroundWhite, type: :model
expect(question.derived?(nil)).to be false
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"3" => { "value" => "Any other White background" },
})
end
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
})
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"2" => { "value" => "Irish" },
"18" => { "value" => "Gypsy or Irish Traveller" },
"20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" },
})
end
end

6
spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)
@ -26,7 +28,7 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"P" => { "value" => "Partner" },
"C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Buyer prefers not to say" },
})

16
spec/models/form/sales/questions/discount_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Discount, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -10,7 +12,7 @@ RSpec.describe Form::Sales::Questions::Discount, type: :model do
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_date: current_collection_start_date))
end
it "has correct page" do
@ -42,16 +44,6 @@ RSpec.describe Form::Sales::Questions::Discount, type: :model do
end
it "has correct max" do
expect(question.max).to eq(100)
end
context "with form start year after 2024" do
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: true, start_date: Time.zone.local(2024, 4, 1)))
end
it "has correct max" do
expect(question.max).to eq(70)
end
expect(question.max).to eq(70)
end
end

292
spec/models/form/sales/questions/mortgage_lender_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::MortgageLender, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -44,203 +45,98 @@ RSpec.describe Form::Sales::Questions::MortgageLender, type: :model do
expect(question.top_guidance_partial).to be_nil
end
context "when form year is before 2024" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"0" => "Don’t know",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"40" => "Other",
})
end
it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(nil, nil)).to eq({
"" => "Select an option",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"40" => "Other",
})
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"0" => "Don’t know",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"41" => "Kent Reliance",
"40" => "Other",
})
end
context "when form year is >= 2024" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"0" => "Don’t know",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"41" => "Kent Reliance",
"40" => "Other",
})
end
it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(nil, nil)).to eq({
"" => "Select an option",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"41" => "Kent Reliance",
"40" => "Other",
})
end
it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(nil, nil)).to eq({
"" => "Select an option",
"1" => "Atom Bank",
"2" => "Barclays Bank PLC",
"3" => "Bath Building Society",
"4" => "Buckinghamshire Building Society",
"5" => "Cambridge Building Society",
"6" => "Coventry Building Society",
"7" => "Cumberland Building Society",
"8" => "Darlington Building Society",
"9" => "Dudley Building Society",
"10" => "Ecology Building Society",
"11" => "Halifax",
"12" => "Hanley Economic Building Society",
"13" => "Hinckley and Rugby Building Society",
"14" => "Holmesdale Building Society",
"15" => "Ipswich Building Society",
"16" => "Leeds Building Society",
"17" => "Lloyds Bank",
"18" => "Mansfield Building Society",
"19" => "Market Harborough Building Society",
"20" => "Melton Mowbray Building Society",
"21" => "Nationwide Building Society",
"22" => "Natwest",
"23" => "Nedbank Private Wealth",
"24" => "Newbury Building Society",
"25" => "OneSavings Bank",
"26" => "Parity Trust",
"27" => "Penrith Building Society",
"28" => "Pepper Homeloans",
"29" => "Royal Bank of Scotland",
"30" => "Santander",
"31" => "Skipton Building Society",
"32" => "Teachers Building Society",
"33" => "The Co-operative Bank",
"34" => "Tipton & Coseley Building Society",
"35" => "TSB",
"36" => "Ulster Bank",
"37" => "Virgin Money",
"38" => "West Bromwich Building Society",
"39" => "Yorkshire Building Society",
"41" => "Kent Reliance",
"40" => "Other",
})
end
end

19
spec/models/form/sales/questions/ownership_scheme_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::OwnershipScheme, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,17 +32,9 @@ RSpec.describe Form::Sales::Questions::OwnershipScheme, type: :model do
expect(question.derived?(nil)).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Yes - a shared ownership scheme" },
"2" => { "value" => "Yes - a discounted ownership scheme" },
"3" => { "value" => "No - this is an outright or other sale" },
})
end
context "with collection year in 2024" do
context "with collection year before 2025" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: false)
end
it "has the correct answer_options" do
@ -55,7 +48,7 @@ RSpec.describe Form::Sales::Questions::OwnershipScheme, type: :model do
context "with collection year on or after 2025" do
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true)
end
it "has the correct answer_options" do

6
spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PersonRelationshipToBuyer1, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, person_index:) }
let(:question_id) { "relat2" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false, person_question_count: 4))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, person_question_count: 4))) }
let(:person_index) { 2 }
it "has correct page" do
@ -27,7 +29,7 @@ RSpec.describe Form::Sales::Questions::PersonRelationshipToBuyer1, type: :model
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"P" => { "value" => "Partner" },
"C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Person prefers not to say" },
})

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

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection, id: "setup", copy_key: "setup") }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,101 +32,45 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
expect(question.derived?(nil)).to be false
end
context "when the form year is before 2024" do
let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics", copy_key: "household_characteristics") }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
context "and there is a single buyer" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyer has seen or been given access to the MHCLG privacy notice" },
})
end
context "and there is a single buyer" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyer has seen the MHCLG 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 MHCLG privacy notice to the buyer before you can submit this log.")
end
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase")
end
it "uses the expected top guidance partial" do
expect(question.top_guidance_partial).to eq("privacy_notice_buyer")
end
context "and there are joint buyers" do
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 MHCLG 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 MHCLG privacy notice to the buyers before you can submit this log.")
end
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase")
end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give the buyer access to the MHCLG privacy notice before you can submit this log.")
end
end
context "when the form year is >= 2024" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase")
end
end
context "and there is a single buyer" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyer has seen or been given access to the MHCLG 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 or give the buyer access to the MHCLG privacy notice before you can submit this log.")
end
context "and there are joint buyers" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase")
end
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 MHCLG privacy notice" },
})
end
context "and there are joint buyers" do
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 MHCLG 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 "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 or give the buyers access to the MHCLG privacy notice before you can submit this log.")
end
it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give the buyers access to the MHCLG privacy notice before you can submit this log.")
end
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.joint_purchase")
end
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.joint_purchase")
end
end
end

Loading…
Cancel
Save