Browse Source

Extract retirement confirmation questions

pull/2707/head
Kat 2 years ago
parent
commit
0191251dd1
  1. 5
      app/models/form/sales/pages/not_retired_value_check.rb
  2. 3
      app/models/form/sales/pages/retirement_value_check.rb
  3. 3
      app/models/form/sales/questions/not_retired_value_check.rb
  4. 3
      app/models/form/sales/questions/retirement_value_check.rb
  5. 21
      config/locales/forms/2023/sales/soft_validations.en.yml
  6. 21
      config/locales/forms/2024/sales/soft_validations.en.yml
  7. 15
      spec/models/form/sales/pages/retirement_value_check_spec.rb

5
app/models/form/sales/pages/not_retired_value_check.rb

@ -7,11 +7,12 @@ class Form::Sales::Pages::NotRetiredValueCheck < Form::Sales::Pages::Person
}, },
] ]
@person_index = person_index @person_index = person_index
@copy_key = "sales.soft_validations.retirement_value_check.max"
@title_text = { @title_text = {
"translation" => "soft_validations.retirement.max.title", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.retirement.max.hint_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
} }
end end

3
app/models/form/sales/pages/retirement_value_check.rb

@ -7,8 +7,9 @@ class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person
}, },
] ]
@person_index = person_index @person_index = person_index
@copy_key = "sales.soft_validations.retirement_value_check.min"
@title_text = { @title_text = {
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age#{person_index}", "key" => "age#{person_index}",

3
app/models/form/sales/questions/not_retired_value_check.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::NotRetiredValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@id = "retirement_value_check" @id = "retirement_value_check"
@check_answer_label = "Retirement confirmation" @copy_key = "sales.soft_validations.retirement_value_check.max"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },
@ -19,6 +19,5 @@ class Form::Sales::Questions::NotRetiredValueCheck < ::Form::Question
], ],
} }
@check_answers_card_number = person_index @check_answers_card_number = person_index
@header = "Are you sure this person isn't retired?"
end end
end end

3
app/models/form/sales/questions/retirement_value_check.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::RetirementValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@id = "retirement_value_check" @id = "retirement_value_check"
@check_answer_label = "Retirement confirmation" @copy_key = "sales.soft_validations.retirement_value_check.min"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },
@ -19,6 +19,5 @@ class Form::Sales::Questions::RetirementValueCheck < ::Form::Question
], ],
} }
@check_answers_card_number = person_index @check_answers_card_number = person_index
@header = "Are you sure this person is retired?"
end end
end end

21
config/locales/forms/2023/sales/soft_validations.en.yml

@ -0,0 +1,21 @@
en:
forms:
2023:
sales:
soft_validations:
retirement_value_check:
max:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person isn't retired?"
title_text: "You told us this person is over 66 and not retired."
informative_text: "The minimum expected retirement age in England is 66."
min:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66."

21
config/locales/forms/2024/sales/soft_validations.en.yml

@ -0,0 +1,21 @@
en:
forms:
2024:
sales:
soft_validations:
retirement_value_check:
max:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person isn't retired?"
title_text: "You told us this person is over 66 and not retired."
informative_text: "The minimum expected retirement age in England is 66."
min:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66."

15
spec/models/form/sales/pages/retirement_value_check_spec.rb

@ -4,7 +4,8 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 1 } let(:person_index) { 1 }
let(:page_id) { "person_1_retirement_value_check" } let(:page_id) { "person_1_retirement_value_check" }
@ -39,7 +40,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age1", "key" => "age1",
@ -77,7 +78,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age2", "key" => "age2",
@ -115,7 +116,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age3", "key" => "age3",
@ -153,7 +154,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age4", "key" => "age4",
@ -191,7 +192,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age5", "key" => "age5",
@ -229,7 +230,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
it "has correct title_text" do it "has correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title", "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "age6", "key" => "age6",

Loading…
Cancel
Save