From 2d2deb1392244e4464cca67cb49934d5d1bf8ad0 Mon Sep 17 00:00:00 2001 From: Dushan Despotovic Date: Thu, 30 Jun 2022 12:31:54 +0100 Subject: [PATCH] fix some failing specs --- spec/helpers/tasklist_helper_spec.rb | 2 +- spec/models/form/setup/questions/location_spec.rb | 2 +- spec/models/form_spec.rb | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index e0e6e94ef..0e13fa805 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe TasklistHelper do let(:empty_case_log) { FactoryBot.create(:case_log) } - let(:case_log) { FactoryBot.create(:case_log, :in_progress) } + let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) } describe "get next incomplete section" do it "returns the first subsection name if it is not completed" do diff --git a/spec/models/form/setup/questions/location_spec.rb b/spec/models/form/setup/questions/location_spec.rb index bef7a7e49..13a23a3f5 100644 --- a/spec/models/form/setup/questions/location_spec.rb +++ b/spec/models/form/setup/questions/location_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Form::Setup::Questions::Location, type: :model do expect(question.id).to eq("location") end - xit "has the correct header" do + it "has the correct header" do expect(question.header).to eq("Which location used by #{scheme.service_name} is this log for?") end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 5b1cb1924..8d363ed12 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -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")