|
|
|
@ -177,8 +177,10 @@ RSpec.describe Form, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "invalidated_page_questions" do |
|
|
|
|
let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) } |
|
|
|
|
|
|
|
|
|
context "when dependencies are not met" do |
|
|
|
|
let(:expected_invalid) { %w[condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] } |
|
|
|
|
let(:expected_invalid) { %w[scheme_id location condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] } |
|
|
|
|
|
|
|
|
|
it "returns an array of question keys whose pages conditions are not met" do |
|
|
|
|
expect(form.invalidated_page_questions(case_log).map(&:id).uniq).to eq(expected_invalid) |
|
|
|
@ -186,7 +188,7 @@ RSpec.describe Form, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with two pages having the same question and only one has dependencies met" do |
|
|
|
|
let(:expected_invalid) { %w[condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] } |
|
|
|
|
let(:expected_invalid) { %w[scheme_id location condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] } |
|
|
|
|
|
|
|
|
|
it "returns an array of question keys whose pages conditions are not met" do |
|
|
|
|
case_log["preg_occ"] = "No" |
|
|
|
@ -195,7 +197,7 @@ RSpec.describe Form, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when a question is marked as `derived` and `depends_on: false`" do |
|
|
|
|
let(:case_log) { FactoryBot.build(:case_log, :in_progress, startdate: Time.utc(2023, 2, 2, 10, 36, 49)) } |
|
|
|
|
let(:case_log) { FactoryBot.build(:case_log, :in_progress, startdate: Time.utc(2022, 4, 2, 10, 36, 49)) } |
|
|
|
|
|
|
|
|
|
it "does not count it's questions as invalidated" do |
|
|
|
|
expect(form.enabled_page_questions(case_log).map(&:id).uniq).to include("tshortfall_known") |
|
|
|
|