6 changed files with 130 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||||
|
class Form::Sales::Questions::Age1 < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "age1" |
||||||
|
@check_answer_label = "Lead buyer’s age" |
||||||
|
@header = "Age" |
||||||
|
@type = "numeric" |
||||||
|
@page = page |
||||||
|
@width = 2 |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,20 @@ |
|||||||
|
class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "age1_known" |
||||||
|
@check_answer_label = "Buyer 1's age" |
||||||
|
@header = "Do you know buyer 1's age?" |
||||||
|
@type = "radio" |
||||||
|
@answer_options = ANSWER_OPTIONS |
||||||
|
@page = page |
||||||
|
@hint_text = "Buyer 1 is the person in the household who does the most paid work. If it's a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." |
||||||
|
@conditional_for = { |
||||||
|
"age1" => [0], |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
ANSWER_OPTIONS = { |
||||||
|
"0" => { "value" => "Yes" }, |
||||||
|
"1" => { "value" => "No" }, |
||||||
|
}.freeze |
||||||
|
end |
@ -0,0 +1,6 @@ |
|||||||
|
class AddAge1ToSalesLogs < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
add_column :sales_logs, :age1, :integer |
||||||
|
add_column :sales_logs, :age1_known, :integer |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,41 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Questions::Age1, 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("age1") |
||||||
|
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("Lead buyer’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(2) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,50 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Questions::Buyer1AgeKnown, 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("age1_known") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct header" do |
||||||
|
expect(question.header).to eq("Do you know buyer 1's age?") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct check_answer_label" do |
||||||
|
expect(question.check_answer_label).to eq("Buyer 1's age") |
||||||
|
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({ |
||||||
|
"age1" => [0], |
||||||
|
}) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct hint" do |
||||||
|
expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it's a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.") |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue