Browse Source

Add tests for question number

CLDC-4146-infer-no-other-partners
oscar-richardson-softwire 2 days ago
parent
commit
e67cf34c0c
  1. 42
      spec/models/form/lettings/questions/person_partner_spec.rb

42
spec/models/form/lettings/questions/person_partner_spec.rb

@ -56,39 +56,49 @@ RSpec.describe Form::Lettings::Questions::PersonPartner, type: :model do
expect(question.check_answers_card_number).to eq(2)
end
context "with person 2 age < 16" do
let(:log) { build(:lettings_log, age2: 10) }
context "and in 2025", metadata: { year: 25 } do
let(:year) { 2025 }
let(:person_question_count) { 4 }
context "and in 2025", metadata: { year: 25 } do
let(:year) { 2025 }
it "has the correct question number" do
expect(question.question_number).to eq(37)
end
context "with person 2 age < 16" do
let(:log) { build(:lettings_log, age2: 10) }
it "is not marked as derived" do
expect(question.derived?(log)).to be false
end
end
context "and in 2026", metadata: { year: 26 } do
let(:year) { 2026 }
context "with person 2 age >= 16" do
let(:log) { build(:lettings_log, age2: 20) }
it "is marked as derived" do
expect(question.derived?(log)).to be true
it "is not marked as derived" do
expect(question.derived?(log)).to be false
end
end
end
context "with person 2 age >= 16" do
let(:log) { build(:lettings_log, age2: 20) }
context "and in 2026", metadata: { year: 26 } do
let(:year) { 2026 }
let(:person_question_count) { 5 }
context "and in 2025", metadata: { year: 25 } do
let(:year) { 2025 }
it "has the correct question number" do
expect(question.question_number).to eq(38)
end
it "is not marked as derived" do
expect(question.derived?(log)).to be false
context "with person 2 age < 16" do
let(:log) { build(:lettings_log, age2: 10) }
it "is marked as derived" do
expect(question.derived?(log)).to be true
end
end
context "and in 2026", metadata: { year: 26 } do
let(:year) { 2026 }
context "with person 2 age >= 16" do
let(:log) { build(:lettings_log, age2: 20) }
it "is not marked as derived" do
expect(question.derived?(log)).to be false

Loading…
Cancel
Save