Browse Source

Update some pages/questions

CLDC-3656-household-characteristics-copy-changes
Kat 2 weeks ago
parent
commit
dfbf19cb6e
  1. 2
      app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
  2. 6
      app/models/form/sales/pages/buyer_interview.rb
  3. 6
      app/models/form/sales/pages/privacy_notice.rb
  4. 6
      app/models/form/sales/questions/buyer_interview.rb
  5. 6
      app/models/form/sales/questions/privacy_notice.rb
  6. 4
      spec/models/form/sales/pages/buyer_interview_spec.rb
  7. 6
      spec/models/form/sales/pages/privacy_notice_spec.rb

2
app/models/form/sales/pages/buyer1_ethnic_background_arab.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundArab < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "buyer_1_ethnic_background_arab" @id = "buyer_1_ethnic_background_arab"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_asian" @copy_key = "sales.household_characteristics.ethnic.ethnic_background_arab"
@depends_on = [{ @depends_on = [{
"ethnic_group" => 4, "ethnic_group" => 4,
}] }]

6
app/models/form/sales/pages/buyer_interview.rb

@ -2,11 +2,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:) def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection) super(id, hsh, subsection)
@joint_purchase = joint_purchase @joint_purchase = joint_purchase
@copy_key = if form.start_year_after_2024? @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
"sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
else
"sales.household_characteristics.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
end end
def questions def questions

6
app/models/form/sales/pages/privacy_notice.rb

@ -1,11 +1,7 @@
class Form::Sales::Pages::PrivacyNotice < ::Form::Page class Form::Sales::Pages::PrivacyNotice < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:) def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection) super(id, hsh, subsection)
@copy_key = if form.start_year_after_2024? @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
"sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
else
"sales.household_characteristics.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
@joint_purchase = joint_purchase @joint_purchase = joint_purchase
end end

6
app/models/form/sales/questions/buyer_interview.rb

@ -2,11 +2,7 @@ class Form::Sales::Questions::BuyerInterview < ::Form::Question
def initialize(id, hsh, page, joint_purchase:) def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page) super(id, hsh, page)
@id = "noint" @id = "noint"
@copy_key = if form.start_year_after_2024? @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
"sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
else
"sales.household_characteristics.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

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

@ -2,11 +2,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
def initialize(id, hsh, page, joint_purchase:) def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page) super(id, hsh, page)
@id = "privacynotice" @id = "privacynotice"
@copy_key = if form.start_year_after_2024? @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
"sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
else
"sales.household_characteristics.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
@type = "checkbox" @type = "checkbox"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@joint_purchase = joint_purchase @joint_purchase = joint_purchase

4
spec/models/form/sales/pages/buyer_interview_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
let(:page_id) { "buyer_interview" } let(:page_id) { "buyer_interview" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) }
let(:subsection) { instance_double(Form::Subsection, form:) } let(:subsection) { instance_double(Form::Subsection, form:, id: "setup") }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -25,6 +25,8 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
end end
context "when form is before 2024" do context "when form is before 2024" do
let(:subsection) { instance_double(Form::Subsection, form:, id: "household_characteristics") }
context "when there are joint buyers" do context "when there are joint buyers" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }

6
spec/models/form/sales/pages/privacy_notice_spec.rb

@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
let(:page_id) { "privacy_notice" } let(:page_id) { "privacy_notice" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection, id: "setup") }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) }
before do before do
@ -32,6 +32,8 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
context "when the form start year is before 2024" do context "when the form start year is before 2024" do
let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase") expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase")
end end
@ -54,6 +56,8 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
context "when the form start year is before 2024" do context "when the form start year is before 2024" do
let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase") expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase")
end end

Loading…
Cancel
Save