From 8caa09a1f736878e49aec929a5f34a57d1bc801b Mon Sep 17 00:00:00 2001 From: ColinBruce Date: Tue, 17 Dec 2024 15:01:20 +0000 Subject: [PATCH] AP-5592: Update proceeding_helper Add the date to the end of the description if has not been added by the proceeding method. This is needed to remove the duplication of date values on the check your answer pages This may be a temp fix while scope limitation texts are reviewed --- app/helpers/proceeding_helper.rb | 12 ++++++--- spec/factories/scope_limitations.rb | 7 +++++ spec/helpers/proceeding_helper_spec.rb | 36 ++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/app/helpers/proceeding_helper.rb b/app/helpers/proceeding_helper.rb index f662d88e1f..d5c5cf9242 100644 --- a/app/helpers/proceeding_helper.rb +++ b/app/helpers/proceeding_helper.rb @@ -21,10 +21,16 @@ def scope_limits(proceeding, scope_type) private def scope_limitation_details(scope_limitation) - scope_limitation_details = [scope_limitation.meaning, scope_limitation.description] + sole_scope_limitation = scope_limitation.proceeding.scope_limitations.where(scope_type: scope_limitation.scope_type).count.eql?(1) + scope_limitation_meaning = if sole_scope_limitation + scope_limitation.meaning + else + "#{scope_limitation.meaning}".html_safe + end + scope_limitation_details = [scope_limitation_meaning, scope_limitation.description] - if scope_limitation.hearing_date - scope_limitation_details << "Date: #{scope_limitation.hearing_date}" + if scope_limitation.hearing_date && scope_limitation.description.exclude?(scope_limitation.hearing_date.to_s) + scope_limitation_details[1] = "#{scope_limitation.description} #{scope_limitation.hearing_date}" elsif scope_limitation.limitation_note scope_limitation_details << "Note: #{scope_limitation.limitation_note}" end diff --git a/spec/factories/scope_limitations.rb b/spec/factories/scope_limitations.rb index 88aedb7fa7..d26370e9bf 100644 --- a/spec/factories/scope_limitations.rb +++ b/spec/factories/scope_limitations.rb @@ -32,5 +32,12 @@ meaning { "General Report" } description { "Limited to obtaining a report from [see additional limitation notes]" } end + + trait :substantive_cv027 do + scope_type { 0 } + code { "CV027" } + meaning { "Hearing/Adjournment" } + description { "Limited to all steps (including any adjournment thereof) up to and including the hearing on" } + end end end diff --git a/spec/helpers/proceeding_helper_spec.rb b/spec/helpers/proceeding_helper_spec.rb index f359d5bb48..2af1e6d7be 100644 --- a/spec/helpers/proceeding_helper_spec.rb +++ b/spec/helpers/proceeding_helper_spec.rb @@ -40,7 +40,7 @@ :scope_limitation, :emergency, meaning: "Special hearing", - description: "Limited to Family Help (Higher) and to all steps necessary to negotiate and conclude a settlement.", + description: "Made up scope to take all steps necessary to negotiate and conclude a settlement on", hearing_date: Date.new(2022, 12, 25), ), create( @@ -64,6 +64,11 @@ meaning: "General report", limitation_note: "This is a note", ), + create( + :scope_limitation, + :substantive_cv027, + hearing_date: Date.new(2024, 12, 25), + ), ] end @@ -80,8 +85,8 @@ let(:scope_type) { "emergency" } it "returns only the emergency scope limitation meanings" do - expect(scope_limitations).to include("Special hearing
Limited to Family Help (Higher) and to all steps necessary to negotiate and conclude a settlement.
Date: 25 December 2022") - expect(scope_limitations).to include("Interim order
Limited to all steps up to and including the hearing on [see additional limitation notes]") + expect(scope_limitations).to include("Special hearing
Made up scope to take all steps necessary to negotiate and conclude a settlement on 25 December 2022") + expect(scope_limitations).to include("Interim order
Limited to all steps up to and including the hearing on [see additional limitation notes]") end end @@ -89,8 +94,29 @@ let(:scope_type) { "substantive" } it "returns only the substantive scope limitation meanings" do - expect(scope_limitations).to include("Final heading
Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.") - expect(scope_limitations).to include("General report
Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.
Note: This is a note") + expect(scope_limitations).to include("Final heading
Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.") + expect(scope_limitations).to include("General report
Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.
Note: This is a note") + expect(scope_limitations).to include("Hearing/Adjournment
Limited to all steps (including any adjournment thereof) up to and including the hearing on 25 December 2024") + end + end + + context "when there is a single scope limitation" do + let(:emergency_scope_limitations) do + [ + create( + :scope_limitation, + :emergency_cv118, + meaning: "Interim order", + ), + ] + end + + context "and the scope type is emergency" do + let(:scope_type) { "emergency" } + + it "returns scope limitation meanings with a bolded span around them" do + expect(scope_limitations).to include("Interim order
Limited to all steps up to and including the hearing on [see additional limitation notes]") + end end end end