Skip to content

Commit bde302b

Browse files
authoredJul 13, 2022
Merge pull request #6015 from alphagov/add_questions_to_check_fire_safety_costs
Add questions and further outcomes to check-fire-safety-costs
2 parents 882b42b + 699707c commit bde302b

13 files changed

+377
-157
lines changed
 

‎app/flows/check_fire_safety_costs_flow.rb

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ def define
44
content_id "29355604-e9a1-499a-9b0c-18abd833f02e"
55
status :draft
66

7+
radio :developer_agreed_to_pay? do
8+
option :yes
9+
option :no
10+
11+
next_node do |response|
12+
if response == "yes"
13+
outcome :developers_pay
14+
else
15+
question :building_over_11_metres?
16+
end
17+
end
18+
end
19+
720
radio :building_over_11_metres? do
821
option :yes
922
option :no
@@ -118,7 +131,7 @@ def define
118131
if response == "yes"
119132
question :percentage_owned?
120133
else
121-
outcome :payment_amount
134+
question :amount_already_paid?
122135
end
123136
end
124137
end
@@ -132,11 +145,22 @@ def define
132145
calculator.valid_percentage_owned?
133146
end
134147

148+
next_node do
149+
question :amount_already_paid?
150+
end
151+
end
152+
153+
money_question :amount_already_paid? do
154+
on_response do |response|
155+
calculator.amount_already_paid = response
156+
end
157+
135158
next_node do
136159
outcome :payment_amount
137160
end
138161
end
139162

163+
outcome :developers_pay
140164
outcome :unlikely_to_need_to_pay
141165
outcome :have_to_pay_owned_by_leaseholders
142166
outcome :have_to_pay_not_main_home
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<% text_for :title do %>
2+
You do not have to pay to fix fire safety problems or replace cladding.
3+
<% end %>
4+
5+
<% govspeak_for :body do %>
6+
You do not have to pay anything towards the cost of fixing:
7+
8+
+ any fault from last 30 years that is a fire safety risk
9+
10+
+ products that are not suitable or do not work
11+
12+
+ poor workmanship
13+
14+
[Find out more about what fire safety problems are covered]().
15+
<% end%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<% text_for :title do %>
2+
You do not have to pay anything more to fix building safety problems or replace cladding
3+
<% end %>
4+
5+
<% govspeak_for :body do %>
6+
Because you've already paid <%= calculator.presented_amount_already_paid %>, you do not have to pay anything towards the cost of fixing:
7+
8+
- any fault from last 30 years that is a fire safety risk
9+
10+
- products that are not suitable or do not work
11+
12+
- poor workmanship
13+
14+
[Find out more about what fire safety problems are covered]().
15+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<% text_for :title do %>
2+
You might have to pay up to <%= calculator.presented_remaining_costs %>
3+
<% end %>
4+
5+
<% govspeak_for :body do %>
6+
You do not have to pay to replace cladding on your building.
7+
8+
The maximum you'll have to pay to fix other fire safety problems is <%= calculator.presented_remaining_costs %>. The freeholder or 'landlord' (whoever is responsible for fixing problems with the building) can only charge you up to <%= calculator.presented_annual_leaseholder_costs%> of this total in a year.
9+
10+
If you sell the property, the person who buys it will have to pay what's left of the total.
11+
12+
##Fire safety problems the cap applies to
13+
14+
The <%= calculator.presented_remaining_costs%> cap applies to the cost of fixing:
15+
16+
- any fault from last 30 years that is a fire safety risk
17+
18+
- products that are not suitable or do not work
19+
20+
- poor workmanship
21+
22+
[Find out more about what fire safety problems are covered by the cap]().
23+
24+
##Responsibilities of the freeholder or landlord
25+
26+
If they want to charge you to fix fire safety problems, the freeholder or landlord must show you a certificate proving that they:
27+
28+
+ were not responsible for causing the problem
29+
30+
+ do not make enough money to pass a ['landlord wealth test'](/)
31+
32+
They will also need to show there is no other way to pay for the work, for example by claiming on a warranty.
33+
34+
If they cannot prove this they will have to fix the fire safety problems themselves.
35+
36+
<% end%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<% text_for :title do %>
2+
You might have to pay up to <%= calculator.presented_remaining_costs %>
3+
<% end %>
4+
5+
<% govspeak_for :body do %>
6+
You do not have to pay to replace cladding on your building.
7+
8+
The maximum you'll have to pay to fix other fire safety problems is <%= calculator.presented_remaining_costs %>. The freeholder or 'landlord' (whoever is responsible for fixing problems with the building) can charge you this amount in one go.
9+
10+
If you sell the property, the person who buys it will have to pay what's left of the total.
11+
12+
##Fire safety problems the cap applies to
13+
14+
The <%= calculator.presented_remaining_costs %> cap applies to the cost of fixing:
15+
16+
- any fault from last 30 years that is a fire safety risk
17+
18+
- products that are not suitable or do not work
19+
20+
- poor workmanship
21+
22+
[Find out more about what fire safety problems are covered by the cap]().
23+
24+
##Responsibilities of the freeholder or landlord
25+
26+
If they want to charge you to fix fire safety problems, the freeholder or landlord must show you a certificate proving that they:
27+
28+
+ were not responsible for causing the problem
29+
30+
+ do not make enough money to pass a ['landlord wealth test'](/)
31+
32+
They will also need to show there is no other way to pay for the work, for example by claiming on a warranty.
33+
34+
If they cannot prove this they will have to fix the fire safety problems themselves.
35+
<% end%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% text_for :title do %>
2+
Your developer will pay.
3+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,9 @@
11
<% if calculator.fully_protected_from_costs?%>
2-
<% text_for :title do %>
3-
You do not have to pay to fix fire safety problems or replace cladding.
4-
<% end %>
5-
6-
<% govspeak_for :body do %>
7-
You do not have to pay anything towards the cost of fixing:
8-
9-
+ any fault from last 30 years that is a fire safety risk
10-
11-
+ products that are not suitable or do not work
12-
13-
+ poor workmanship
14-
15-
[Find out more about what fire safety problems are covered]().
16-
<% end %>
17-
<% else %>
18-
<% text_for :title do %>
19-
You might have to pay up to <%= calculator.presented_leaseholder_costs %>
20-
<% end %>
21-
22-
<% govspeak_for :body do %>
23-
You do not have to pay to replace cladding on your building.
24-
25-
The maximum you'll have to pay to fix other fire safety problems is <%= calculator.presented_leaseholder_costs %>. The freeholder or 'landlord' (whoever is responsible for fixing problems with the building) can only charge you up to <%= calculator.presented_annual_leaseholder_costs %> of this total in a year.
26-
27-
Any costs you've already paid since 2017 are taken off this total.
28-
29-
If you sell the property, the person who buys it will have to pay what's left of the total.
30-
31-
You do not have to pay any costs if your property was built by a [developer who's agreed to pay for fire safety works](/guidance/list-of-developers-who-have-signed-building-safety-repairs-pledge). You'll get a letter from your developer if this applies to you.
32-
33-
##Fire safety problems the cap applies to
34-
35-
The <%= calculator.presented_leaseholder_costs %> cap applies to the cost of fixing:
36-
37-
- any fault from last 30 years that is a fire safety risk
38-
39-
- products that are not suitable or do not work
40-
41-
- poor workmanship
42-
43-
[Find out more about what fire safety problems are covered by the cap]().
44-
45-
##Responsibilities of the freeholder or landlord
46-
47-
If they want to charge you to fix fire safety problems, the freeholder or landlord must show you a certificate proving that they:
48-
49-
+ were not responsible for causing the problem
50-
51-
+ do not make enough money to pass a ['landlord wealth test'](/)
52-
53-
They will also need to show there is no other way to pay for the work, for example by claiming on a warranty.
54-
55-
If they cannot prove this they will have to fix the fire safety problems themselves.
56-
<% end%>
2+
<%= render partial: "fully_protected_from_costs" %>
3+
<% elsif calculator.remaining_costs_more_than_annual_leaseholder_costs? %>
4+
<%= render partial: "remaining_costs_leaseholder_annual_cap", locals: {calculator: calculator} %>
5+
<% elsif calculator.fully_repaid? %>
6+
<%= render partial: "fully_repaid", locals: {calculator: calculator} %>
7+
<% elsif calculator.remaining_costs_less_than_annual_leaseholder_costs? %>
8+
<%= render partial: "remaining_costs_no_annual_cap", locals: {calculator: calculator} %>
579
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% text_for :title do %>
2+
How much have you already paid for fixing fire safety problems with the building?
3+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% text_for :title do %>
2+
Was your property built by a developer who's agreed to pay for fire safety works?
3+
<% end %>
4+
5+
<% text_for :hint do %>
6+
You'll have received a letter from your developer if this applies to you.
7+
<% end %>
8+
9+
<% options(
10+
"yes": "Yes",
11+
"no": "No"
12+
) %>

‎app/flows/check_fire_safety_costs_flow/start.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<% end %>
88

99
<% govspeak_for :body do %>
10-
If you're a leaseholder in England, check whether you'll have to pay to replace cladding or to fix other fire safety problems with your property.
10+
If you're a leaseholder in England, check whether you'll have to pay to replace cladding or to fix other fire safety problems with your building.
1111

1212
If you have more than one property, answer for one property at a time.
1313

‎lib/smart_answer/calculators/check_fire_safety_costs_calculator.rb

+26-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class CheckFireSafetyCostsCalculator
77
:value_of_property,
88
:live_in_london,
99
:shared_ownership,
10-
:percentage_owned
10+
:percentage_owned,
11+
:amount_already_paid
1112

1213
FIRST_VALID_YEAR = 1900
1314
LAST_VALID_YEAR = 2022
@@ -43,14 +44,30 @@ def fully_protected_from_costs?
4344
under_valuation_limit_living_inside_london || under_valuation_limit_living_outside_london
4445
end
4546

46-
def presented_leaseholder_costs
47-
@presented_leaseholder_costs ||= cost_as_currency(leaseholder_costs)
48-
end
49-
5047
def presented_annual_leaseholder_costs
5148
@presented_annual_leaseholder_costs ||= cost_as_currency(annual_leaseholder_costs)
5249
end
5350

51+
def presented_remaining_costs
52+
@presented_remaining_costs ||= cost_as_currency(remaining_costs)
53+
end
54+
55+
def presented_amount_already_paid
56+
@presented_amount_already_paid ||= cost_as_currency(@amount_already_paid)
57+
end
58+
59+
def remaining_costs_more_than_annual_leaseholder_costs?
60+
remaining_costs.to_f > annual_leaseholder_costs
61+
end
62+
63+
def remaining_costs_less_than_annual_leaseholder_costs?
64+
remaining_costs.to_f <= annual_leaseholder_costs
65+
end
66+
67+
def fully_repaid?
68+
remaining_costs <= 0
69+
end
70+
5471
private
5572

5673
def default_uprating_value
@@ -85,6 +102,10 @@ def annual_leaseholder_costs
85102
leaseholder_costs / ANNUAL_COST_OFFSET
86103
end
87104

105+
def remaining_costs
106+
(leaseholder_costs - @amount_already_paid.to_f).ceil
107+
end
108+
88109
def cost_as_currency(costs)
89110
number_to_currency(costs, unit: "£", precision: 0)
90111
end

‎test/flows/check_fire_safety_costs_flow_test.rb

+142-23
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,29 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
1212
assert_rendered_start_page
1313
end
1414

15+
context "question: developer_agreed_to_pay?" do
16+
setup { testing_node :developer_agreed_to_pay? }
17+
18+
should "render the question" do
19+
assert_rendered_question
20+
end
21+
22+
context "next_node" do
23+
should "have an outcome of developers_pay? if yes" do
24+
assert_next_node :developers_pay, for_response: "yes"
25+
end
26+
27+
should "have an outcome of building_over_11_metres if no" do
28+
assert_next_node :building_over_11_metres?, for_response: "no"
29+
end
30+
end
31+
end
32+
1533
context "question: building_over_11_metres?" do
16-
setup { testing_node :building_over_11_metres? }
34+
setup do
35+
testing_node :building_over_11_metres?
36+
add_responses developer_agreed_to_pay?: "no"
37+
end
1738

1839
should "render the question" do
1940
assert_rendered_question
@@ -33,7 +54,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
3354
context "question: owned_by_leaseholders?" do
3455
setup do
3556
testing_node :owned_by_leaseholders?
36-
add_responses building_over_11_metres?: "yes"
57+
add_responses developer_agreed_to_pay?: "no",
58+
building_over_11_metres?: "yes"
3759
end
3860

3961
should "render the question" do
@@ -54,7 +76,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
5476
context "question: own_more_than_3_properties?" do
5577
setup do
5678
testing_node :own_more_than_3_properties?
57-
add_responses building_over_11_metres?: "yes",
79+
add_responses developer_agreed_to_pay?: "no",
80+
building_over_11_metres?: "yes",
5881
owned_by_leaseholders?: "no"
5982
end
6083

@@ -76,7 +99,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
7699
context "question: main_home_february_2022?" do
77100
setup do
78101
testing_node :main_home_february_2022?
79-
add_responses building_over_11_metres?: "yes",
102+
add_responses developer_agreed_to_pay?: "no",
103+
building_over_11_metres?: "yes",
80104
owned_by_leaseholders?: "no",
81105
own_more_than_3_properties?: "yes"
82106
end
@@ -99,7 +123,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
99123
context "question: purchased_pre_or_post_february_2022?" do
100124
setup do
101125
testing_node :purchased_pre_or_post_february_2022?
102-
add_responses building_over_11_metres?: "yes",
126+
add_responses developer_agreed_to_pay?: "no",
127+
building_over_11_metres?: "yes",
103128
owned_by_leaseholders?: "no",
104129
own_more_than_3_properties?: "yes",
105130
main_home_february_2022?: "yes"
@@ -119,7 +144,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
119144
context "question: year_of_purchase?" do
120145
setup do
121146
testing_node :year_of_purchase?
122-
add_responses building_over_11_metres?: "yes",
147+
add_responses developer_agreed_to_pay?: "no",
148+
building_over_11_metres?: "yes",
123149
owned_by_leaseholders?: "no",
124150
own_more_than_3_properties?: "yes",
125151
main_home_february_2022?: "yes",
@@ -148,7 +174,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
148174
context "question: value_of_propety?" do
149175
setup do
150176
testing_node :value_of_property?
151-
add_responses building_over_11_metres?: "yes",
177+
add_responses developer_agreed_to_pay?: "no",
178+
building_over_11_metres?: "yes",
152179
owned_by_leaseholders?: "no",
153180
own_more_than_3_properties?: "yes",
154181
main_home_february_2022?: "yes",
@@ -170,7 +197,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
170197
context "question: live_in_london?" do
171198
setup do
172199
testing_node :live_in_london?
173-
add_responses building_over_11_metres?: "yes",
200+
add_responses developer_agreed_to_pay?: "no",
201+
building_over_11_metres?: "yes",
174202
owned_by_leaseholders?: "no",
175203
own_more_than_3_properties?: "yes",
176204
main_home_february_2022?: "yes",
@@ -193,7 +221,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
193221
context "question: shared_ownership?" do
194222
setup do
195223
testing_node :shared_ownership?
196-
add_responses building_over_11_metres?: "yes",
224+
add_responses developer_agreed_to_pay?: "no",
225+
building_over_11_metres?: "yes",
197226
owned_by_leaseholders?: "no",
198227
own_more_than_3_properties?: "yes",
199228
main_home_february_2022?: "yes",
@@ -212,16 +241,17 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
212241
assert_next_node :percentage_owned?, for_response: "yes"
213242
end
214243

215-
should "have an outcome of payment_amount if no" do
216-
assert_next_node :payment_amount, for_response: "no"
244+
should "have next node of amoount_already_paid if no" do
245+
assert_next_node :amount_already_paid?, for_response: "no"
217246
end
218247
end
219248
end
220249

221250
context "question: percentage_owned?" do
222251
setup do
223252
testing_node :percentage_owned?
224-
add_responses building_over_11_metres?: "yes",
253+
add_responses developer_agreed_to_pay?: "no",
254+
building_over_11_metres?: "yes",
225255
owned_by_leaseholders?: "no",
226256
own_more_than_3_properties?: "yes",
227257
main_home_february_2022?: "yes",
@@ -237,8 +267,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
237267
end
238268

239269
context "next_node" do
240-
should "have an outcome of payment_amount" do
241-
assert_next_node :payment_amount, for_response: "50.4"
270+
should "have next node of amount_already_paid" do
271+
assert_next_node :amount_already_paid?, for_response: "50.4"
242272
end
243273

244274
should "have an invalid response if percentage is over 100" do
@@ -251,11 +281,50 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
251281
end
252282
end
253283

284+
context "question: amount_already_paid?" do
285+
setup do
286+
testing_node :amount_already_paid?
287+
add_responses developer_agreed_to_pay?: "no",
288+
building_over_11_metres?: "yes",
289+
owned_by_leaseholders?: "no",
290+
own_more_than_3_properties?: "yes",
291+
main_home_february_2022?: "yes",
292+
purchased_pre_or_post_february_2022?: "pre_feb_2022",
293+
year_of_purchase?: "2019",
294+
value_of_property?: "100000",
295+
live_in_london?: "yes",
296+
shared_ownership?: "yes",
297+
percentage_owned?: "20"
298+
end
299+
300+
should "render the question" do
301+
assert_rendered_question
302+
end
303+
304+
context "next_node" do
305+
should "have an outcome of payment_amount" do
306+
assert_next_node :payment_amount, for_response: "2000"
307+
end
308+
end
309+
end
310+
254311
context "outcomes" do
312+
context "when developers have agreed to pay" do
313+
setup do
314+
testing_node :developers_pay
315+
add_responses developer_agreed_to_pay?: "yes"
316+
end
317+
318+
should "render outcome text" do
319+
assert_rendered_outcome text: "Your developer will pay"
320+
end
321+
end
322+
255323
context "when building is under 11 metres" do
256324
setup do
257325
testing_node :unlikely_to_need_to_pay
258-
add_responses building_over_11_metres?: "no"
326+
add_responses developer_agreed_to_pay?: "no",
327+
building_over_11_metres?: "no"
259328
end
260329

261330
should "render outcome text" do
@@ -266,7 +335,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
266335
context "when building is over 11 metres and user owns freehold" do
267336
setup do
268337
testing_node :have_to_pay_owned_by_leaseholders
269-
add_responses building_over_11_metres?: "yes",
338+
add_responses developer_agreed_to_pay?: "no",
339+
building_over_11_metres?: "yes",
270340
owned_by_leaseholders?: "yes"
271341
end
272342

@@ -278,7 +348,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
278348
context "when building is over 11 metres, user doesn't own freehold, user has over 3 propeties and wasn't main home in Feb 2022" do
279349
setup do
280350
testing_node :have_to_pay_not_main_home
281-
add_responses building_over_11_metres?: "yes",
351+
add_responses developer_agreed_to_pay?: "no",
352+
building_over_11_metres?: "yes",
282353
owned_by_leaseholders?: "no",
283354
own_more_than_3_properties?: "yes",
284355
main_home_february_2022?: "no"
@@ -292,7 +363,8 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
292363
context "when a user has a level of ownership and valuation that protects them from costs" do
293364
setup do
294365
testing_node :payment_amount
295-
add_responses building_over_11_metres?: "yes",
366+
add_responses developer_agreed_to_pay?: "no",
367+
building_over_11_metres?: "yes",
296368
owned_by_leaseholders?: "no",
297369
own_more_than_3_properties?: "no",
298370
main_home_february_2022?: "yes",
@@ -301,32 +373,79 @@ class CheckFireSafetyCostsFlowTest < ActiveSupport::TestCase
301373
value_of_property?: "100000",
302374
live_in_london?: "yes",
303375
shared_ownership?: "yes",
304-
percentage_owned?: "15"
376+
percentage_owned?: "15",
377+
amount_already_paid?: "100"
305378
end
306379

307380
should "render outcome text" do
308381
assert_rendered_outcome text: "You do not have to pay to fix fire safety problems or replace cladding."
309382
end
310383
end
311384

312-
context "when a user has a level of ownership and valuation that means they have to pay costs" do
385+
context "when a user has to pay costs, and the amount owing is more than the annual leaseholder costs" do
313386
setup do
314387
testing_node :payment_amount
315-
add_responses building_over_11_metres?: "yes",
388+
add_responses developer_agreed_to_pay?: "no",
389+
building_over_11_metres?: "yes",
316390
owned_by_leaseholders?: "no",
317391
own_more_than_3_properties?: "no",
318392
main_home_february_2022?: "yes",
319393
purchased_pre_or_post_february_2022?: "pre_feb_2022",
320394
year_of_purchase?: "2019",
321395
value_of_property?: "2000000",
322396
live_in_london?: "yes",
323-
shared_ownership?: "no"
397+
shared_ownership?: "no",
398+
amount_already_paid?: "15000"
324399
end
325400

326401
should "render outcome text" do
327-
assert_rendered_outcome text: "You might have to pay up to £100,000"
402+
assert_rendered_outcome text: "You might have to pay up to £85,000"
328403
assert_rendered_outcome text: "The freeholder or ‘landlord’ (whoever is responsible for fixing problems with the building) can only charge you up to £10,000 of this total in a year."
329404
end
330405
end
406+
407+
context "when a user has to pay costs,and they have already repaid the full amount" do
408+
setup do
409+
testing_node :payment_amount
410+
add_responses developer_agreed_to_pay?: "no",
411+
building_over_11_metres?: "yes",
412+
owned_by_leaseholders?: "no",
413+
own_more_than_3_properties?: "no",
414+
main_home_february_2022?: "yes",
415+
purchased_pre_or_post_february_2022?: "pre_feb_2022",
416+
year_of_purchase?: "2019",
417+
value_of_property?: "2000000",
418+
live_in_london?: "yes",
419+
shared_ownership?: "no",
420+
amount_already_paid?: "100100"
421+
end
422+
423+
should "render outcome text" do
424+
assert_rendered_outcome text: "You do not have to pay anything more to fix building safety problems or replace cladding"
425+
assert_rendered_outcome text: "Because you’ve already paid £100,100, you do not have to pay anything towards the cost of fixing"
426+
end
427+
end
428+
429+
context "when a user has to pay costs, and the amount owing is less than the annual leaseholder costs" do
430+
setup do
431+
testing_node :payment_amount
432+
add_responses developer_agreed_to_pay?: "no",
433+
building_over_11_metres?: "yes",
434+
owned_by_leaseholders?: "no",
435+
own_more_than_3_properties?: "no",
436+
main_home_february_2022?: "yes",
437+
purchased_pre_or_post_february_2022?: "pre_feb_2022",
438+
year_of_purchase?: "2019",
439+
value_of_property?: "2000000",
440+
live_in_london?: "yes",
441+
shared_ownership?: "no",
442+
amount_already_paid?: "95000"
443+
end
444+
445+
should "render outcome text" do
446+
assert_rendered_outcome text: "You might have to pay up to £5,000"
447+
assert_rendered_outcome text: "The freeholder or ‘landlord’ (whoever is responsible for fixing problems with the building) can charge you this amount in one go"
448+
end
449+
end
331450
end
332451
end

‎test/unit/calculators/check_fire_safety_costs_calculator_test.rb

+57-72
Original file line numberDiff line numberDiff line change
@@ -72,83 +72,68 @@ class CheckFireSafetyCostsCalculatorTest < ActiveSupport::TestCase
7272
end
7373
end
7474

75-
context "#presented_leaseholder_costs" do
76-
context "not living in London with value between outer London limit and one million" do
77-
setup do
78-
@calculator.stubs(:uprated_value_of_property).returns(CheckFireSafetyCostsCalculator::OUTSIDE_LONDON_VALUATION_LIMIT)
79-
@calculator.live_in_london = "no"
80-
end
81-
82-
should "return £10,000 if not shared ownership" do
83-
@calculator.shared_ownership = "no"
84-
assert_equal @calculator.presented_leaseholder_costs, "£10,000"
85-
end
86-
87-
should "return percentage owned multipled by ten thousand if shared ownership" do
88-
@calculator.shared_ownership = "yes"
89-
@calculator.percentage_owned = 0.50
90-
assert_equal @calculator.presented_leaseholder_costs, "£5,000"
91-
end
92-
end
93-
94-
context "living in London with value between inner London limit and one million" do
95-
setup do
96-
@calculator.stubs(:uprated_value_of_property).returns(CheckFireSafetyCostsCalculator::INSIDE_LONDON_VALUATION_LIMIT)
97-
@calculator.live_in_london = "yes"
98-
end
99-
100-
should "return £15,000 if not shared ownership" do
101-
@calculator.shared_ownership = "no"
102-
assert_equal @calculator.presented_leaseholder_costs, "£15,000"
103-
end
104-
105-
should "return percentage owned multipled by fifteen thousand if shared ownership" do
106-
@calculator.shared_ownership = "yes"
107-
@calculator.percentage_owned = 0.50
108-
assert_equal @calculator.presented_leaseholder_costs, "£7,500"
109-
end
110-
end
111-
112-
context "uprated value is over one million" do
113-
setup do
114-
@calculator.stubs(:uprated_value_of_property).returns(CheckFireSafetyCostsCalculator::ONE_MILLION)
115-
end
116-
117-
should "return £50,000 if not shared ownership" do
118-
@calculator.shared_ownership = "no"
119-
assert_equal @calculator.presented_leaseholder_costs, "£50,000"
120-
end
121-
122-
should "return percentage owned multipled by fifty thousand if shared ownership" do
123-
@calculator.shared_ownership = "yes"
124-
@calculator.percentage_owned = 0.50
125-
assert_equal @calculator.presented_leaseholder_costs, "£25,000"
126-
end
127-
end
128-
129-
context "uprated value is over two million" do
130-
setup do
131-
@calculator.stubs(:uprated_value_of_property).returns(CheckFireSafetyCostsCalculator::TWO_MILLION)
132-
end
133-
134-
should "return £100,000 if not shared ownership" do
135-
@calculator.shared_ownership = "no"
136-
assert_equal @calculator.presented_leaseholder_costs, "£100,000"
137-
end
138-
139-
should "return percentage owned multipled by one hunderd thousand if shared ownership" do
140-
@calculator.shared_ownership = "yes"
141-
@calculator.percentage_owned = 0.50
142-
assert_equal @calculator.presented_leaseholder_costs, "£50,000"
143-
end
144-
end
145-
end
146-
14775
context "#presented_annual_leaseholder_costs" do
14876
should "return one tenth of the leaseholder_costs as a pound value" do
14977
@calculator.stubs(:leaseholder_costs).returns(100_000)
15078
assert_equal @calculator.presented_annual_leaseholder_costs, "£10,000"
15179
end
15280
end
81+
82+
context "#presented_remaining_costs" do
83+
should "return the leaseholder costs minus the amount already paid, rounded up" do
84+
@calculator.stubs(:leaseholder_costs).returns(100_000)
85+
@calculator.amount_already_paid = "50000.01"
86+
assert_equal @calculator.presented_remaining_costs, "£50,000"
87+
end
88+
end
89+
90+
context "#presented_amount_already_paid" do
91+
should "return the amount already paid as currency, rounded up" do
92+
@calculator.amount_already_paid = "50000.01"
93+
assert_equal @calculator.presented_amount_already_paid, "£50,000"
94+
end
95+
end
96+
97+
context "remaining_costs_more_than_annual_leaseholder_costs" do
98+
should "be true if remaining_costs is more than annual_leaseholder costs" do
99+
@calculator.stubs(:leaseholder_costs).returns(15_000)
100+
@calculator.amount_already_paid = "1"
101+
assert @calculator.remaining_costs_more_than_annual_leaseholder_costs?
102+
end
103+
104+
should "be false if remaining_costs is less than annual_leaseholder" do
105+
@calculator.stubs(:leaseholder_costs).returns(15_000)
106+
@calculator.amount_already_paid = "50000"
107+
assert_not @calculator.remaining_costs_more_than_annual_leaseholder_costs?
108+
end
109+
end
110+
111+
context "remaining_costs_less_than_annual_leaseholder_costs" do
112+
should "be true if remaining_costs is less than annual_leaseholder costs" do
113+
@calculator.stubs(:leaseholder_costs).returns(15_000)
114+
@calculator.amount_already_paid = "50000"
115+
assert @calculator.remaining_costs_less_than_annual_leaseholder_costs?
116+
end
117+
118+
should "be false if remaining_costs is more than annual_leaseholder" do
119+
@calculator.stubs(:leaseholder_costs).returns(15_000)
120+
@calculator.amount_already_paid = "1"
121+
assert_not @calculator.remaining_costs_less_than_annual_leaseholder_costs?
122+
end
123+
end
124+
125+
context "fully_repaid?" do
126+
should "be true if remaining_costs is 0" do
127+
@calculator.stubs(:leaseholder_costs).returns(15_000)
128+
@calculator.amount_already_paid = "50000"
129+
assert @calculator.fully_repaid?
130+
end
131+
132+
should "be false if remaining_costs is more than 0" do
133+
@calculator.stubs(:leaseholder_costs).returns(15_000)
134+
@calculator.amount_already_paid = "1"
135+
assert_not @calculator.fully_repaid?
136+
end
137+
end
153138
end
154139
end

0 commit comments

Comments
 (0)
Please sign in to comment.