Skip to content

Commit 588a3c2

Browse files
floehopperchrisroos
authored andcommitted
Use ERB tags to interpolate values in template
These were not dealt with automatically by the conversion script. I've also elected to inline the phrases from the i18n YAML file into the flow `precalculate` blocks. Note that I've had to mark on of them as HTML-safe to avoid an apostrophe being HTML-escaped. This isn't ideal, but I'd hope that these strings would move into the ERB template or a helper method where this would be easier to deal with.
1 parent 434fbf6 commit 588a3c2

7 files changed

+32
-12
lines changed

lib/smart_answer_flows/calculate-your-child-maintenance.rb

+25-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def define
2929
end
3030

3131
precalculate :paying_or_receiving_hint do
32-
PhraseList.new(:"#{paying_or_receiving}_hint")
32+
if paying_or_receiving == "pay"
33+
"Enter the total number of children - including children that you have family based arrangements for. They will be included in the calculation and you'll need to supply information about them when arranging Child Maintenance.".html_safe
34+
else
35+
"Enter children from 1 partner only and make a separate calculation for each partner."
36+
end
3337
end
3438

3539
calculate :number_of_children do |response|
@@ -47,7 +51,11 @@ def define
4751
option "no"
4852

4953
precalculate :benefits_title do
50-
PhraseList.new(:"#{paying_or_receiving}_benefits")
54+
if paying_or_receiving == "pay"
55+
"Do you get any of these benefits?"
56+
else
57+
"Does the parent paying child maintenance get any of these benefits?"
58+
end
5159
end
5260

5361
calculate :calculator do
@@ -72,7 +80,11 @@ def define
7280
money_question :gross_income_of_payee? do
7381

7482
precalculate :income_title do
75-
PhraseList.new(:"#{paying_or_receiving}_income")
83+
if paying_or_receiving == "pay"
84+
"What is your weekly gross income?"
85+
else
86+
"What is the weekly gross income of the parent paying child maintenance?"
87+
end
7688
end
7789

7890
next_node_calculation :rate_type do |response|
@@ -101,7 +113,11 @@ def define
101113
value_question :how_many_other_children_in_payees_household?, parse: Integer do
102114

103115
precalculate :number_of_children_title do
104-
PhraseList.new(:"#{paying_or_receiving}_number_of_children")
116+
if paying_or_receiving == "pay"
117+
"How many other children live in your household?"
118+
else
119+
"How many other children live in the household of the parent paying child maintenance?"
120+
end
105121
end
106122

107123
calculate :calculator do |response|
@@ -120,7 +136,11 @@ def define
120136
option 4
121137

122138
precalculate :how_many_nights_title do
123-
PhraseList.new(:"#{paying_or_receiving}_how_many_nights")
139+
if paying_or_receiving == "pay"
140+
"On average, how many nights a year do the children stay over with you?"
141+
else
142+
"On average, how many nights a year do the children stay over with the parent paying child maintenance?"
143+
end
124144
end
125145

126146
calculate :child_maintenance_payment do |response|

lib/smart_answer_flows/calculate-your-child-maintenance/questions/gets_benefits.govspeak.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
2-
%{benefits_title}
2+
<%= benefits_title %>
33
<% end %>
44

55
<% options(

lib/smart_answer_flows/calculate-your-child-maintenance/questions/gross_income_of_payee.govspeak.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
2-
%{income_title}
2+
<%= income_title %>
33
<% end %>
44

55
<% content_for :hint do %>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
2-
How many children are you %{paying_or_receiving_text} child maintenance for?
2+
How many children are you <%= paying_or_receiving_text %> child maintenance for?
33
<% end %>
44

55
<% options(
@@ -9,5 +9,5 @@
99
) %>
1010

1111
<% content_for :hint do %>
12-
%{paying_or_receiving_hint}
12+
<%= paying_or_receiving_hint %>
1313
<% end %>

lib/smart_answer_flows/calculate-your-child-maintenance/questions/how_many_nights_children_stay_with_payee.govspeak.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
2-
%{how_many_nights_title}
2+
<%= how_many_nights_title %>
33
<% end %>
44

55
<% options(

lib/smart_answer_flows/calculate-your-child-maintenance/questions/how_many_other_children_in_payees_household.govspeak.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
2-
%{number_of_children_title}
2+
<%= number_of_children_title %>
33
<% end %>
44

55
<% content_for :hint do %>

test/integration/smart_answer_flows/calculate_child_maintenance_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CalculateChildMaintentanceTest < ActiveSupport::TestCase
3131

3232
should "ask do you get any of these benefits" do
3333
assert_current_node :gets_benefits?
34-
assert_phrase_list :paying_or_receiving_hint, [:pay_hint]
34+
assert_state_variable :paying_or_receiving_hint, "Enter the total number of children - including children that you have family based arrangements for. They will be included in the calculation and you'll need to supply information about them when arranging Child Maintenance."
3535
end
3636

3737
context "answer yes" do

0 commit comments

Comments
 (0)