kosiakkatrina
2 years ago
committed by
GitHub
34 changed files with 1009 additions and 908 deletions
@ -1,19 +0,0 @@
|
||||
class Form::Sales::Pages::Person1Age < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "person_1_age" |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [ |
||||
{ "details_known_1" => 1 }, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Person1AgeKnown.new(nil, nil, self), |
||||
Form::Sales::Questions::Person1Age.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -1,19 +0,0 @@
|
||||
class Form::Sales::Pages::Person2Age < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "person_2_age" |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [ |
||||
{ "details_known_2" => 1 }, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Person2AgeKnown.new(nil, nil, self), |
||||
Form::Sales::Questions::Person2Age.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -1,19 +0,0 @@
|
||||
class Form::Sales::Pages::Person3Age < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "person_3_age" |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [ |
||||
{ "details_known_3" => 1 }, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Person3AgeKnown.new(nil, nil, self), |
||||
Form::Sales::Questions::Person3Age.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -1,19 +0,0 @@
|
||||
class Form::Sales::Pages::Person4Age < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "person_4_age" |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [ |
||||
{ "details_known_4" => 1 }, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Person4AgeKnown.new(nil, nil, self), |
||||
Form::Sales::Questions::Person4Age.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,29 @@
|
||||
class Form::Sales::Pages::PersonAge < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [ |
||||
{ "details_known_#{person_display_number(PERSON_INDEX)}" => 1, "jointpur" => joint_purchase? ? 1 : 2 }, |
||||
] |
||||
end |
||||
|
||||
PERSON_INDEX = { |
||||
"person_1_age" => 2, |
||||
"person_2_age" => 3, |
||||
"person_3_age" => 4, |
||||
"person_4_age" => 5, |
||||
"person_1_age_joint_purchase" => 3, |
||||
"person_2_age_joint_purchase" => 4, |
||||
"person_3_age_joint_purchase" => 5, |
||||
"person_4_age_joint_purchase" => 6, |
||||
}.freeze |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::PersonAgeKnown.new("age#{person_database_number(PERSON_INDEX)}_known", nil, self), |
||||
Form::Sales::Questions::PersonAge.new("age#{person_database_number(PERSON_INDEX)}", nil, self), |
||||
] |
||||
end |
||||
end |
@ -1,16 +0,0 @@
|
||||
class Form::Sales::Questions::Person1Age < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age3" |
||||
@check_answer_label = "Person 1’s age" |
||||
@header = "Age" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 3 |
||||
@inferred_check_answers_value = { |
||||
"condition" => { "age3_known" => 1 }, |
||||
"value" => "Not known", |
||||
} |
||||
@check_answers_card_number = 3 |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
class Form::Sales::Questions::Person1AgeKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age3_known" |
||||
@check_answer_label = "Person 1’s age known?" |
||||
@header = "Do you know person 1’s age?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@hint_text = "" |
||||
@conditional_for = { |
||||
"age3" => [0], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"age3_known" => 0, |
||||
}, |
||||
{ |
||||
"age3_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = 3 |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -1,16 +0,0 @@
|
||||
class Form::Sales::Questions::Person2Age < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age4" |
||||
@check_answer_label = "Person 2’s age" |
||||
@header = "Age" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 3 |
||||
@inferred_check_answers_value = { |
||||
"condition" => { "age4_known" => 1 }, |
||||
"value" => "Not known", |
||||
} |
||||
@check_answers_card_number = 4 |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
class Form::Sales::Questions::Person2AgeKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age4_known" |
||||
@check_answer_label = "Person 2’s age known?" |
||||
@header = "Do you know person 2’s age?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@hint_text = "" |
||||
@conditional_for = { |
||||
"age4" => [0], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"age4_known" => 0, |
||||
}, |
||||
{ |
||||
"age4_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = 4 |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -1,16 +0,0 @@
|
||||
class Form::Sales::Questions::Person3Age < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age5" |
||||
@check_answer_label = "Person 3’s age" |
||||
@header = "Age" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 3 |
||||
@inferred_check_answers_value = { |
||||
"condition" => { "age5_known" => 1 }, |
||||
"value" => "Not known", |
||||
} |
||||
@check_answers_card_number = 5 |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
class Form::Sales::Questions::Person3AgeKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age5_known" |
||||
@check_answer_label = "Person 3’s age known?" |
||||
@header = "Do you know person 3’s age?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@hint_text = "" |
||||
@conditional_for = { |
||||
"age5" => [0], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"age5_known" => 0, |
||||
}, |
||||
{ |
||||
"age5_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = 5 |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -1,16 +0,0 @@
|
||||
class Form::Sales::Questions::Person4Age < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age6" |
||||
@check_answer_label = "Person 4’s age" |
||||
@header = "Age" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 3 |
||||
@inferred_check_answers_value = { |
||||
"condition" => { "age6_known" => 1 }, |
||||
"value" => "Not known", |
||||
} |
||||
@check_answers_card_number = 6 |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
class Form::Sales::Questions::Person4AgeKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "age6_known" |
||||
@check_answer_label = "Person 4’s age known?" |
||||
@header = "Do you know person 4’s age?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@hint_text = "" |
||||
@conditional_for = { |
||||
"age6" => [0], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"age6_known" => 0, |
||||
}, |
||||
{ |
||||
"age6_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = 6 |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -0,0 +1,23 @@
|
||||
class Form::Sales::Questions::PersonAge < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@check_answer_label = "Person #{person_display_number(PERSON_INDEX)}’s age" |
||||
@header = "Age" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 3 |
||||
@inferred_check_answers_value = { |
||||
"condition" => { "age#{person_database_number(PERSON_INDEX)}_known" => 1 }, |
||||
"value" => "Not known", |
||||
} |
||||
@check_answers_card_number = person_database_number(PERSON_INDEX) |
||||
end |
||||
|
||||
PERSON_INDEX = { |
||||
"age2" => 2, |
||||
"age3" => 3, |
||||
"age4" => 4, |
||||
"age5" => 5, |
||||
"age6" => 6, |
||||
}.freeze |
||||
end |
@ -0,0 +1,38 @@
|
||||
class Form::Sales::Questions::PersonAgeKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@check_answer_label = "Person #{person_display_number(PERSON_INDEX)}’s age known?" |
||||
@header = "Do you know person #{person_display_number(PERSON_INDEX)}’s age?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@hint_text = "" |
||||
@conditional_for = { |
||||
"age#{person_database_number(PERSON_INDEX)}" => [0], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"age#{person_database_number(PERSON_INDEX)}_known" => 0, |
||||
}, |
||||
{ |
||||
"age#{person_database_number(PERSON_INDEX)}_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
@check_answers_card_number = person_database_number(PERSON_INDEX) |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}.freeze |
||||
|
||||
PERSON_INDEX = { |
||||
"age2_known" => 2, |
||||
"age3_known" => 3, |
||||
"age4_known" => 4, |
||||
"age5_known" => 5, |
||||
"age6_known" => 6, |
||||
}.freeze |
||||
end |
@ -1,37 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Person1Age, 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[age3_known age3]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_1_age") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
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( |
||||
[ |
||||
{ "details_known_1" => 1 }, |
||||
], |
||||
) |
||||
end |
||||
end |
@ -1,35 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Person2Age, 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[age4_known age4]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_age") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
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( |
||||
[{ "details_known_2" => 1 }], |
||||
) |
||||
end |
||||
end |
@ -1,35 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Person3Age, 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[age5_known age5]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_3_age") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
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( |
||||
[{ "details_known_3" => 1 }], |
||||
) |
||||
end |
||||
end |
@ -1,35 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Person4Age, 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[age6_known age6]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_4_age") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
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( |
||||
[{ "details_known_4" => 1 }], |
||||
) |
||||
end |
||||
end |
@ -0,0 +1,185 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::PersonAge, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { "person_1_age" } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
context "with a non joint purchase" do |
||||
context "and person 1" do |
||||
let(:page_id) { "person_1_age" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age2_known age2]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_1_age") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_1" => 1, "jointpur" => 2 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:page_id) { "person_2_age" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age3_known age3]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_age") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_2" => 1, "jointpur" => 2 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:page_id) { "person_3_age" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age4_known age4]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_3_age") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_3" => 1, "jointpur" => 2 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:page_id) { "person_4_age" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age5_known age5]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_4_age") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_4" => 1, "jointpur" => 2 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "with joint purchase" do |
||||
context "and person 1" do |
||||
let(:page_id) { "person_1_age_joint_purchase" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age3_known age3]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_1_age_joint_purchase") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_1" => 1, "jointpur" => 1 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:page_id) { "person_2_age_joint_purchase" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age4_known age4]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_2_age_joint_purchase") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_2" => 1, "jointpur" => 1 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:page_id) { "person_3_age_joint_purchase" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age5_known age5]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_3_age_joint_purchase") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_3" => 1, "jointpur" => 1 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:page_id) { "person_4_age_joint_purchase" } |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[age6_known age6]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("person_4_age_joint_purchase") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq( |
||||
[ |
||||
{ "details_known_4" => 1, "jointpur" => 1 }, |
||||
], |
||||
) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,69 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person1AgeKnown, 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("age3_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 1’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age known?") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age3" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("") |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age3_known" => 0, |
||||
}, |
||||
{ |
||||
"age3_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
@ -1,52 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person1Age, 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("age3") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Age") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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 the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age3_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
@ -1,62 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person2AgeKnown, 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("age4_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 2’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age known?") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age4" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("") |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [{ "age4_known" => 0 }, { "age4_known" => 1 }], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
@ -1,52 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person2Age, 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("age4") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Age") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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 the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age4_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
@ -1,62 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person3AgeKnown, 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("age5_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 3’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age known?") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age5" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("") |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [{ "age5_known" => 0 }, { "age5_known" => 1 }], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
@ -1,52 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person3Age, 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("age5") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Age") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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 the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age5_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
@ -1,62 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person4AgeKnown, 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("age6_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 4’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age known?") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age6" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("") |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [{ "age6_known" => 0 }, { "age6_known" => 1 }], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(6) |
||||
end |
||||
end |
@ -1,52 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Person4Age, 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("age6") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Age") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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 the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age6_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(6) |
||||
end |
||||
end |
@ -0,0 +1,400 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::PersonAgeKnown, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { "age3_known" } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page) } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age") |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
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 hint" do |
||||
expect(question.hint_text).to eq("") |
||||
end |
||||
|
||||
context "with a non joint purchase" do |
||||
context "and person 1" do |
||||
let(:question_id) { "age2_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age2_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 1’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age2" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age2_known" => 0, |
||||
}, |
||||
{ |
||||
"age2_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(2) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:question_id) { "age3_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_2_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age3_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 2’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age3" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age3_known" => 0, |
||||
}, |
||||
{ |
||||
"age3_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:question_id) { "age4_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_3_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age4_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 3’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age4" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age4_known" => 0, |
||||
}, |
||||
{ |
||||
"age4_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:question_id) { "age5_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_4_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age5_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 4’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age5" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age5_known" => 0, |
||||
}, |
||||
{ |
||||
"age5_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "with a joint purchase" do |
||||
context "and person 1" do |
||||
let(:question_id) { "age3_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age3_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 1’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age3" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age3_known" => 0, |
||||
}, |
||||
{ |
||||
"age3_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:question_id) { "age4_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_2_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age4_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 2’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age4" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age4_known" => 0, |
||||
}, |
||||
{ |
||||
"age4_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:question_id) { "age5_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_3_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age5_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 3’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age5" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age5_known" => 0, |
||||
}, |
||||
{ |
||||
"age5_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:question_id) { "age6_known" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_4_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age6_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Do you know person 4’s age?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age known?") |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"age6" => [0], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hidden_in_check_answers" do |
||||
expect(question.hidden_in_check_answers).to eq( |
||||
{ |
||||
"depends_on" => [ |
||||
{ |
||||
"age6_known" => 0, |
||||
}, |
||||
{ |
||||
"age6_known" => 1, |
||||
}, |
||||
], |
||||
}, |
||||
) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(6) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,285 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::PersonAge, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { "age3" } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page) } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age") |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Age") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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 |
||||
|
||||
context "with not a joint purchase" do |
||||
context "and person 1" do |
||||
let(:question_id) { "age2" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age2") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age2_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(2) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:question_id) { "age3" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_2_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age3") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age3_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:question_id) { "age4" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_3_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age4") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age4_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:question_id) { "age5" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_4_age") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age5") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age5_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "with a joint purchase" do |
||||
context "and person 1" do |
||||
let(:question_id) { "age3" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_1_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age3") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 1’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age3_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(3) |
||||
end |
||||
end |
||||
|
||||
context "and person 2" do |
||||
let(:question_id) { "age4" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_2_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age4") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 2’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age4_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(4) |
||||
end |
||||
end |
||||
|
||||
context "and person 3" do |
||||
let(:question_id) { "age5" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_3_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age5") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 3’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age5_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(5) |
||||
end |
||||
end |
||||
|
||||
context "and person 4" do |
||||
let(:question_id) { "age6" } |
||||
|
||||
before do |
||||
allow(page).to receive(:id).and_return("person_4_age_joint_purchase") |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("age6") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Person 4’s age") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(3) |
||||
end |
||||
|
||||
it "has the correct inferred check answers value" do |
||||
expect(question.inferred_check_answers_value).to eq({ |
||||
"condition" => { "age6_known" => 1 }, |
||||
"value" => "Not known", |
||||
}) |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(6) |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue