8 changed files with 0 additions and 328 deletions
@ -1,15 +0,0 @@
|
||||
class Form::Sales::Questions::GenderDescription1 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "gender_description1" |
||||
@type = "text" |
||||
@check_answers_card_number = 1 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def derived?(log) |
||||
log.gender_same_as_sex1 != 2 |
||||
end |
||||
end |
||||
@ -1,15 +0,0 @@
|
||||
class Form::Sales::Questions::GenderDescription2 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "gender_description2" |
||||
@type = "text" |
||||
@check_answers_card_number = 2 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def derived?(log) |
||||
log.gender_same_as_sex2 != 2 |
||||
end |
||||
end |
||||
@ -1,32 +0,0 @@
|
||||
class Form::Sales::Questions::GenderSameAsSex1 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "gender_same_as_sex1" |
||||
@type = "radio" |
||||
@check_answers_card_number = 1 |
||||
@conditional_for = { "gender_description1" => [2] } |
||||
@inferred_check_answers_value = [{ "condition" => { "gender_same_as_sex1" => 2 }, "value" => "No" }] |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No, enter gender identity" }, |
||||
"divider" => { "value" => true }, |
||||
"3" => { "value" => "Buyer prefers not to say" }, |
||||
}.freeze |
||||
|
||||
def answer_options |
||||
ANSWER_OPTIONS |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def label_from_value(value, _log = nil, _user = nil) |
||||
return unless value |
||||
|
||||
return "Prefers not to say" if value == 3 |
||||
|
||||
super |
||||
end |
||||
end |
||||
@ -1,32 +0,0 @@
|
||||
class Form::Sales::Questions::GenderSameAsSex2 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "gender_same_as_sex2" |
||||
@type = "radio" |
||||
@check_answers_card_number = 2 |
||||
@conditional_for = { "gender_description2" => [2] } |
||||
@inferred_check_answers_value = [{ "condition" => { "gender_same_as_sex2" => 2 }, "value" => "No" }] |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No, enter gender identity" }, |
||||
"divider" => { "value" => true }, |
||||
"3" => { "value" => "Buyer prefers not to say" }, |
||||
}.freeze |
||||
|
||||
def answer_options |
||||
ANSWER_OPTIONS |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def label_from_value(value, _log = nil, _user = nil) |
||||
return unless value |
||||
|
||||
return "Prefers not to say" if value == 3 |
||||
|
||||
super |
||||
end |
||||
end |
||||
@ -1,60 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::GenderDescription1, 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) } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } |
||||
|
||||
before do |
||||
allow(page).to receive(:subsection).and_return(subsection) |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("gender_description1") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("text") |
||||
end |
||||
|
||||
it "has expected check answers card number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct inferred_check_answers_value" do |
||||
expect(question.inferred_check_answers_value).to be_nil |
||||
end |
||||
|
||||
context "when gender_same_as_sex1 is 'Yes'" do |
||||
let(:log) { build(:sales_log, gender_same_as_sex1: 1) } |
||||
|
||||
it "is marked as derived" do |
||||
expect(question.derived?(log)).to be true |
||||
end |
||||
end |
||||
|
||||
context "when gender_same_as_sex1 is 'No'" do |
||||
let(:log) { build(:sales_log, gender_same_as_sex1: 2) } |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(log)).to be false |
||||
end |
||||
end |
||||
|
||||
context "when gender_same_as_sex1 is 'Prefers not to say'" do |
||||
let(:log) { build(:sales_log, gender_same_as_sex1: 3) } |
||||
|
||||
it "is marked as derived" do |
||||
expect(question.derived?(log)).to be true |
||||
end |
||||
end |
||||
end |
||||
@ -1,52 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::GenderDescription2, 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) } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } |
||||
|
||||
before do |
||||
allow(page).to receive(:subsection).and_return(subsection) |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("gender_description2") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("text") |
||||
end |
||||
|
||||
it "has expected check answers card number" do |
||||
expect(question.check_answers_card_number).to eq(2) |
||||
end |
||||
|
||||
it "has the correct inferred_check_answers_value" do |
||||
expect(question.inferred_check_answers_value).to be_nil |
||||
end |
||||
|
||||
context "when gender_same_as_sex2 is 'Yes'" do |
||||
let(:log) { build(:sales_log, gender_same_as_sex2: 1) } |
||||
|
||||
it "is marked as derived" do |
||||
expect(question.derived?(log)).to be true |
||||
end |
||||
end |
||||
|
||||
context "when gender_same_as_sex2 is 'No'" do |
||||
let(:log) { build(:sales_log, gender_same_as_sex2: 2) } |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(log)).to be false |
||||
end |
||||
end |
||||
end |
||||
@ -1,65 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::GenderSameAsSex1, 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) } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } |
||||
|
||||
before do |
||||
allow(page).to receive(:subsection).and_return(subsection) |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("gender_same_as_sex1") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(nil)).to be false |
||||
end |
||||
|
||||
it "has expected check answers card number" do |
||||
expect(question.check_answers_card_number).to eq(1) |
||||
end |
||||
|
||||
it "has the correct conditional_for" do |
||||
expect(question.conditional_for).to eq({ "gender_description1" => [2] }) |
||||
end |
||||
|
||||
it "has the correct inferred_check_answers_value" do |
||||
expect(question.inferred_check_answers_value).to eq([{ "condition" => { "gender_same_as_sex1" => 2 }, "value" => "No" }]) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No, enter gender identity" }, |
||||
"divider" => { "value" => true }, |
||||
"3" => { "value" => "Buyer prefers not to say" }, |
||||
}) |
||||
end |
||||
|
||||
it "returns correct label_from_value for 'No'" do |
||||
expect(question.label_from_value(2)).to eq("No, enter gender identity") |
||||
end |
||||
|
||||
it "returns correct label_from_value for 'Prefers not to say'" do |
||||
expect(question.label_from_value(3)).to eq("Prefers not to say") |
||||
end |
||||
|
||||
it "returns nil label_from_value for nil" do |
||||
expect(question.label_from_value(nil)).to be_nil |
||||
end |
||||
end |
||||
@ -1,57 +0,0 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::GenderSameAsSex2, 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) } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } |
||||
|
||||
before do |
||||
allow(page).to receive(:subsection).and_return(subsection) |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("gender_same_as_sex2") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(nil)).to be false |
||||
end |
||||
|
||||
it "has expected check answers card number" do |
||||
expect(question.check_answers_card_number).to eq(2) |
||||
end |
||||
|
||||
it "has the correct conditional_for" do |
||||
expect(question.conditional_for).to eq({ "gender_description2" => [2] }) |
||||
end |
||||
|
||||
it "has the correct inferred_check_answers_value" do |
||||
expect(question.inferred_check_answers_value).to eq([{ "condition" => { "gender_same_as_sex2" => 2 }, "value" => "No" }]) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No, enter gender identity" }, |
||||
"divider" => { "value" => true }, |
||||
"3" => { "value" => "Buyer prefers not to say" }, |
||||
}) |
||||
end |
||||
|
||||
it "returns correct label_from_value for 'Prefers not to say'" do |
||||
expect(question.label_from_value(3)).to eq("Prefers not to say") |
||||
end |
||||
end |
||||
Loading…
Reference in new issue