|
|
@ -6,8 +6,15 @@ RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do |
|
|
|
let(:question_id) { nil } |
|
|
|
let(:question_id) { nil } |
|
|
|
let(:question_definition) { nil } |
|
|
|
let(:question_definition) { nil } |
|
|
|
let(:page) { instance_double(Form::Page) } |
|
|
|
let(:page) { instance_double(Form::Page) } |
|
|
|
|
|
|
|
let(:subsection) { instance_double(Form::Subsection) } |
|
|
|
|
|
|
|
let(:form) { instance_double(Form) } |
|
|
|
let(:joint_purchase) { true } |
|
|
|
let(:joint_purchase) { true } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(page).to receive(:subsection).and_return(subsection) |
|
|
|
|
|
|
|
allow(subsection).to receive(:form).and_return(form) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has correct page" do |
|
|
|
it "has correct page" do |
|
|
|
expect(question.page).to eq(page) |
|
|
|
expect(question.page).to eq(page) |
|
|
|
end |
|
|
|
end |
|
|
@ -42,10 +49,6 @@ RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do |
|
|
|
expect(question.type).to eq("radio") |
|
|
|
expect(question.type).to eq("radio") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "is not marked as derived" do |
|
|
|
|
|
|
|
expect(question.derived?).to be false |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "has the correct displayed_answer_options" do |
|
|
|
it "has the correct displayed_answer_options" do |
|
|
|
expect(question.displayed_answer_options(nil)).to eq({ |
|
|
|
expect(question.displayed_answer_options(nil)).to eq({ |
|
|
|
"1" => { "value" => "Yes" }, |
|
|
|
"1" => { "value" => "Yes" }, |
|
|
@ -68,4 +71,24 @@ RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do |
|
|
|
it "has the correct hint" do |
|
|
|
it "has the correct hint" do |
|
|
|
expect(question.hint_text).to eq(nil) |
|
|
|
expect(question.hint_text).to eq(nil) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when form year is before 2024" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "is not marked as derived" do |
|
|
|
|
|
|
|
expect(question.derived?).to be false |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when form year is >= 2024" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "is marked as derived" do |
|
|
|
|
|
|
|
expect(question.derived?).to be true |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|