Skip to content

Commit

Permalink
AP-5592: Update proceeding_helper
Browse files Browse the repository at this point in the history
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
  • Loading branch information
colinbruce committed Dec 17, 2024
1 parent 27dc907 commit 8caa09a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
12 changes: 9 additions & 3 deletions app/helpers/proceeding_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
"<span class=\"single-scope-limit-heading\">#{scope_limitation.meaning}</span>".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
Expand Down
7 changes: 7 additions & 0 deletions spec/factories/scope_limitations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 31 additions & 5 deletions spec/helpers/proceeding_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand All @@ -80,17 +85,38 @@
let(:scope_type) { "emergency" }

it "returns only the emergency scope limitation meanings" do
expect(scope_limitations).to include("Special hearing<br>Limited to Family Help (Higher) and to all steps necessary to negotiate and conclude a settlement.<br>Date: 25 December 2022")
expect(scope_limitations).to include("Interim order<br>Limited to all steps up to and including the hearing on [see additional limitation notes]")
expect(scope_limitations).to include("<span class=\"single-scope-limit-heading\">Special hearing</span><br>Made up scope to take all steps necessary to negotiate and conclude a settlement on 25 December 2022")
expect(scope_limitations).to include("<span class=\"single-scope-limit-heading\">Interim order</span><br>Limited to all steps up to and including the hearing on [see additional limitation notes]")
end
end

context "when scope type is substantive" do
let(:scope_type) { "substantive" }

it "returns only the substantive scope limitation meanings" do
expect(scope_limitations).to include("Final heading<br>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<br>Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.<br>Note: This is a note")
expect(scope_limitations).to include("<span class=\"single-scope-limit-heading\">Final heading</span><br>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("<span class=\"single-scope-limit-heading\">General report</span><br>Limited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order.<br>Note: This is a note")
expect(scope_limitations).to include("<span class=\"single-scope-limit-heading\">Hearing/Adjournment</span><br>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<br>Limited to all steps up to and including the hearing on [see additional limitation notes]")
end
end
end
end
Expand Down

0 comments on commit 8caa09a

Please sign in to comment.