From ae4debc3521f00aedad7f81f398e042e83390ba0 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 13 Sep 2023 16:09:52 +0100 Subject: [PATCH] Don't set started at on preliminary assessment sections This doesn't count as part of the assessment, so we shouldn't be recording the started at date of the assessment as part of the preliminary check. --- app/services/update_assessment_section.rb | 2 +- spec/services/update_assessment_section_spec.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/services/update_assessment_section.rb b/app/services/update_assessment_section.rb index 736817eb6d..4dcb1bbd6b 100644 --- a/app/services/update_assessment_section.rb +++ b/app/services/update_assessment_section.rb @@ -76,7 +76,7 @@ def create_timeline_event(old_state:) end def update_assessment_started_at - return if assessment.started_at + return if assessment.started_at || assessment_section.preliminary assessment.update!(started_at: Time.zone.now) end diff --git a/spec/services/update_assessment_section_spec.rb b/spec/services/update_assessment_section_spec.rb index 63c890bd1e..f8b08b4bbc 100644 --- a/spec/services/update_assessment_section_spec.rb +++ b/spec/services/update_assessment_section_spec.rb @@ -121,7 +121,15 @@ context "with an existing assessment started at" do before { assessment.update!(started_at: Date.new(2021, 1, 1)) } - it "doesn't change the assessor" do + it "doesn't change the started" do + expect { subject }.to_not change(assessment, :started_at) + end + end + + context "with a preliminary assessment section" do + before { assessment_section.update!(preliminary: true) } + + it "doesn't change the started" do expect { subject }.to_not change(assessment, :started_at) end end