Browse Source
* Separate the validations, remove irrelevant tests * Remove relevant lettings 2023 validations from 24 * Update validations for 2024 lettings * Separate sales validations * Infer child uner 16 for sales * Update sales validations * Update tests * Add validations to all relevant fields * Add a 2023 context * Undo some 2024 validations * Remove another validation, update test names * Remove child option hint * Update person age hint * Add ecstat buyer validation * Add custom ecstat BU errors * Skip working situation for child in sales * Add child under 16 validation to 2024, do not reset ecstat * Add soft validation columns * Add partner under 16 soft validation * Add multiple partners soft validations * Remove child option for buyer 2 * Update CSVs * Check hhmemb exists * refactor * Display child option for lettings * Remove wrong tests * More testspull/2330/head
kosiakkatrina
9 months ago
committed by
GitHub
76 changed files with 2255 additions and 432 deletions
@ -0,0 +1,26 @@
|
||||
class Form::Lettings::Pages::MultiplePartnersValueCheck < Form::Page |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super(id, hsh, subsection) |
||||
@depends_on = [ |
||||
{ |
||||
"multiple_partners?" => true, |
||||
}, |
||||
] |
||||
@person_index = person_index |
||||
@title_text = { |
||||
"translation" => "soft_validations.multiple_partners_lettings.title", |
||||
"arguments" => [], |
||||
} |
||||
@informative_text = {} |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index), |
||||
] |
||||
end |
||||
|
||||
def interruption_screen_question_ids |
||||
%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8] |
||||
end |
||||
end |
@ -0,0 +1,32 @@
|
||||
class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super(id, hsh, subsection) |
||||
@depends_on = [ |
||||
{ |
||||
"person_#{person_index}_partner_under_16?" => true, |
||||
}, |
||||
] |
||||
@person_index = person_index |
||||
@title_text = { |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age#{person_index}", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
} |
||||
@informative_text = {} |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index), |
||||
] |
||||
end |
||||
|
||||
def interruption_screen_question_ids |
||||
["age#{@person_index}", "relat#{@person_index}"] |
||||
end |
||||
end |
@ -0,0 +1,24 @@
|
||||
class Form::Lettings::Questions::MultiplePartnersValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "multiple_partners_value_check" |
||||
@check_answer_label = "Multiple partners confirmation" |
||||
@type = "interruption_screen" |
||||
@answer_options = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"multiple_partners_value_check" => 0, |
||||
}, |
||||
{ |
||||
"multiple_partners_value_check" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = person_index |
||||
@header = "Are you sure this is correct?" |
||||
end |
||||
end |
@ -0,0 +1,24 @@
|
||||
class Form::Lettings::Questions::PartnerUnder16ValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "partner_under_16_value_check" |
||||
@check_answer_label = "Partner under 16 confirmation" |
||||
@type = "interruption_screen" |
||||
@answer_options = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"partner_under_16_value_check" => 0, |
||||
}, |
||||
{ |
||||
"partner_under_16_value_check" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = person_index |
||||
@header = "Are you sure this is correct?" |
||||
end |
||||
end |
@ -0,0 +1,26 @@
|
||||
class Form::Sales::Pages::MultiplePartnersValueCheck < Form::Sales::Pages::Person |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super |
||||
@depends_on = [ |
||||
{ |
||||
"multiple_partners?" => true, |
||||
}, |
||||
] |
||||
@person_index = person_index |
||||
@title_text = { |
||||
"translation" => "soft_validations.multiple_partners_sales.title", |
||||
"arguments" => [], |
||||
} |
||||
@informative_text = {} |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index), |
||||
] |
||||
end |
||||
|
||||
def interruption_screen_question_ids |
||||
%w[relat2 relat3 relat4 relat5 relat6] |
||||
end |
||||
end |
@ -0,0 +1,32 @@
|
||||
class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super |
||||
@depends_on = [ |
||||
{ |
||||
"person_#{person_index}_partner_under_16?" => true, |
||||
}, |
||||
] |
||||
@person_index = person_index |
||||
@title_text = { |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age#{person_index}", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
} |
||||
@informative_text = {} |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index), |
||||
] |
||||
end |
||||
|
||||
def interruption_screen_question_ids |
||||
["age#{@person_index}", "relat#{@person_index}"] |
||||
end |
||||
end |
@ -0,0 +1,24 @@
|
||||
class Form::Sales::Questions::MultiplePartnersValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "multiple_partners_value_check" |
||||
@check_answer_label = "Multiple partners confirmation" |
||||
@type = "interruption_screen" |
||||
@answer_options = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"multiple_partners_value_check" => 0, |
||||
}, |
||||
{ |
||||
"multiple_partners_value_check" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = person_index |
||||
@header = "Are you sure this is correct?" |
||||
end |
||||
end |
@ -0,0 +1,24 @@
|
||||
class Form::Sales::Questions::PartnerUnder16ValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "partner_under_16_value_check" |
||||
@check_answer_label = "Partner under 16 confirmation" |
||||
@type = "interruption_screen" |
||||
@answer_options = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"partner_under_16_value_check" => 0, |
||||
}, |
||||
{ |
||||
"partner_under_16_value_check" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = person_index |
||||
@header = "Are you sure this is correct?" |
||||
end |
||||
end |
@ -0,0 +1,13 @@
|
||||
class AddRelationshipValueCheckFields < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :lettings_logs, bulk: true do |t| |
||||
t.column :partner_under_16_value_check, :integer |
||||
t.column :multiple_partners_value_check, :integer |
||||
end |
||||
|
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :partner_under_16_value_check, :integer |
||||
t.column :multiple_partners_value_check, :integer |
||||
end |
||||
end |
||||
end |
|
|
|
|
|
|
|
|
|
|
|
|
@ -0,0 +1,91 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } |
||||
|
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:person_index) { 1 } |
||||
|
||||
let(:page_id) { "multiple_partners_value_check" } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to be_nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "is interruption screen page" do |
||||
expect(page.interruption_screen?).to eq(true) |
||||
end |
||||
|
||||
context "with person 1" do |
||||
let(:person_index) { 1 } |
||||
let(:page_id) { "multiple_partners_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.multiple_partners_lettings.title", |
||||
"arguments" => [], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8]) |
||||
end |
||||
end |
||||
|
||||
context "with person 2" do |
||||
let(:person_index) { 2 } |
||||
let(:page_id) { "person_2_multiple_partners_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.multiple_partners_lettings.title", |
||||
"arguments" => [], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8]) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,255 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } |
||||
|
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:person_index) { 1 } |
||||
|
||||
let(:page_id) { "partner_under_16_value_check" } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to be_nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "is interruption screen page" do |
||||
expect(page.interruption_screen?).to eq(true) |
||||
end |
||||
|
||||
context "with person 1" do |
||||
let(:person_index) { 1 } |
||||
let(:page_id) { "partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age1", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1]) |
||||
end |
||||
end |
||||
|
||||
context "with person 2" do |
||||
let(:person_index) { 2 } |
||||
let(:page_id) { "person_2_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age2", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2]) |
||||
end |
||||
end |
||||
|
||||
context "with person 3" do |
||||
let(:person_index) { 3 } |
||||
let(:page_id) { "person_3_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_3_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age3", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3]) |
||||
end |
||||
end |
||||
|
||||
context "with person 4" do |
||||
let(:person_index) { 4 } |
||||
let(:page_id) { "person_4_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_4_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age4", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4]) |
||||
end |
||||
end |
||||
|
||||
context "with person 5" do |
||||
let(:person_index) { 5 } |
||||
let(:page_id) { "person_5_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_5_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age5", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5]) |
||||
end |
||||
end |
||||
|
||||
context "with person 6" do |
||||
let(:person_index) { 6 } |
||||
let(:page_id) { "person_6_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_6_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_lettings.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age6", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6]) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,61 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::MultiplePartnersValueCheck, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } |
||||
|
||||
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("multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Are you sure this is correct?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Multiple partners confirmation") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("interruption_screen") |
||||
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 be_nil |
||||
end |
||||
|
||||
it "has a correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq({ |
||||
"depends_on" => [ |
||||
{ |
||||
"multiple_partners_value_check" => 0, |
||||
}, |
||||
{ |
||||
"multiple_partners_value_check" => 1, |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,61 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::PartnerUnder16ValueCheck, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } |
||||
|
||||
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("partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Are you sure this is correct?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Partner under 16 confirmation") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("interruption_screen") |
||||
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 be_nil |
||||
end |
||||
|
||||
it "has a correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq({ |
||||
"depends_on" => [ |
||||
{ |
||||
"partner_under_16_value_check" => 0, |
||||
}, |
||||
{ |
||||
"partner_under_16_value_check" => 1, |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,91 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } |
||||
|
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:person_index) { 1 } |
||||
|
||||
let(:page_id) { "multiple_partners_value_check" } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to be_nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "is interruption screen page" do |
||||
expect(page.interruption_screen?).to eq(true) |
||||
end |
||||
|
||||
context "with person 1" do |
||||
let(:person_index) { 1 } |
||||
let(:page_id) { "multiple_partners_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.multiple_partners_sales.title", |
||||
"arguments" => [], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6]) |
||||
end |
||||
end |
||||
|
||||
context "with person 2" do |
||||
let(:person_index) { 2 } |
||||
let(:page_id) { "person_2_multiple_partners_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.multiple_partners_sales.title", |
||||
"arguments" => [], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6]) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,255 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } |
||||
|
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:person_index) { 1 } |
||||
|
||||
let(:page_id) { "partner_under_16_value_check" } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to be_nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "is interruption screen page" do |
||||
expect(page.interruption_screen?).to eq(true) |
||||
end |
||||
|
||||
context "with person 1" do |
||||
let(:person_index) { 1 } |
||||
let(:page_id) { "partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age1", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1]) |
||||
end |
||||
end |
||||
|
||||
context "with person 2" do |
||||
let(:person_index) { 2 } |
||||
let(:page_id) { "person_2_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age2", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2]) |
||||
end |
||||
end |
||||
|
||||
context "with person 3" do |
||||
let(:person_index) { 3 } |
||||
let(:page_id) { "person_3_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_3_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age3", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3]) |
||||
end |
||||
end |
||||
|
||||
context "with person 4" do |
||||
let(:person_index) { 4 } |
||||
let(:page_id) { "person_4_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_4_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age4", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4]) |
||||
end |
||||
end |
||||
|
||||
context "with person 5" do |
||||
let(:person_index) { 5 } |
||||
let(:page_id) { "person_5_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_5_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age5", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5]) |
||||
end |
||||
end |
||||
|
||||
context "with person 6" do |
||||
let(:person_index) { 6 } |
||||
let(:page_id) { "person_6_partner_under_16_value_check" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_6_partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }]) |
||||
end |
||||
|
||||
it "has correct title_text" do |
||||
expect(page.title_text).to eq({ |
||||
"translation" => "soft_validations.partner_under_16_sales.title", |
||||
"arguments" => [ |
||||
{ |
||||
"key" => "age6", |
||||
"label" => true, |
||||
"i18n_template" => "age", |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
|
||||
it "has correct informative_text" do |
||||
expect(page.informative_text).to eq({}) |
||||
end |
||||
|
||||
it "has correct interruption_screen_question_ids" do |
||||
expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6]) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,61 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::MultiplePartnersValueCheck, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } |
||||
|
||||
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("multiple_partners_value_check") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Are you sure this is correct?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Multiple partners confirmation") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("interruption_screen") |
||||
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 be_nil |
||||
end |
||||
|
||||
it "has a correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq({ |
||||
"depends_on" => [ |
||||
{ |
||||
"multiple_partners_value_check" => 0, |
||||
}, |
||||
{ |
||||
"multiple_partners_value_check" => 1, |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,61 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::PartnerUnder16ValueCheck, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } |
||||
|
||||
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("partner_under_16_value_check") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Are you sure this is correct?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Partner under 16 confirmation") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("interruption_screen") |
||||
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 be_nil |
||||
end |
||||
|
||||
it "has a correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq({ |
||||
"depends_on" => [ |
||||
{ |
||||
"partner_under_16_value_check" => 0, |
||||
}, |
||||
{ |
||||
"partner_under_16_value_check" => 1, |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
end |
Loading…
Reference in new issue