Skip to content

Commit

Permalink
Merge pull request #6773 from alphagov/274-update-logic-for-check-ben…
Browse files Browse the repository at this point in the history
…efits

Updates check benefits logic for childcare policy
  • Loading branch information
syed-ali-tw committed May 13, 2024
2 parents e332887 + 6d016c8 commit 81ceb3d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
12 changes: 6 additions & 6 deletions config/smart_answers/check_benefits_financial_support_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
title: 15 hours of free childcare for 3 and 4-year-olds
description: <p>You can get 570 hours of free childcare per year with an approved childcare provider if your child is 3 or 4 years old and has not started school full-time.</p>
condition: eligible_for_15hrs_free_childcare_3_4yr_olds?
url: /help-with-childcare-costs/free-childcare-and-education-for-2-to-4-year-olds
url: /help-with-childcare-costs/free-childcare-and-education-for-3-to-4-year-olds
url_text: Find out how to get free childcare for 3 and 4-year-olds
group: Help with childcare costs
countries:
Expand All @@ -217,11 +217,11 @@
countries:
- scotland
- name: 30hrs_free_childcare_3_4yrs_england
title: 30 hours of free childcare
description: <p>You may be able to get 30 hours of free childcare with an approved childcare provider if you’re working and your child is 3 or 4 years old and has not started school full-time.</p>
condition: eligible_for_30hrs_free_childcare_3_4yrs?
url: /30-hours-free-childcare
url_text: Check if you’re eligible for 30 hours free childcare
title: Free childcare if you’re working
description: <p>You may be able to get free childcare with an approved childcare provider if you’re working and your child is between 9 months and 4 years old (and has not started school full-time).</p>
condition: eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
url: /check-eligible-free-childcare-if-youre-working
url_text: Check if you’re eligible for free childcare if you're working
group: Help with childcare costs
countries:
- england
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ def eligible_for_15hrs_free_childcare_3_4yr_olds?
@children_living_with_you == "yes" && eligible_child_ages?(%w[3_to_4])
end

def eligible_for_30hrs_free_childcare_3_4yrs?
def eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
age_groups = %w[1_or_under 2 3_to_4]

@are_you_working == "yes" &&
@children_living_with_you == "yes" &&
eligible_child_ages?(%w[3_to_4])
eligible_child_ages?(age_groups)
end

def eligible_for_funded_early_learning_and_childcare?
Expand Down
14 changes: 8 additions & 6 deletions test/flows/check_benefits_financial_support_flow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,15 @@ class CheckBenefitsFinancialSupportFlowTest < ActiveSupport::TestCase
end
end

should "render 30 hours of free childcare when eligible" do
add_responses where_do_you_live: "england",
children_living_with_you: "yes",
age_of_children: "3_to_4"
should "render free childcare if you’re working when eligible" do
%w[1_or_under,2,3_to_4].each do |age|
add_responses where_do_you_live: "england",
children_living_with_you: "yes",
age_of_children: age

assert_rendered_outcome text: "30 hours of free childcare"
assert_rendered_outcome text: "Check if you’re eligible for 30 hours free childcare"
assert_rendered_outcome text: "Free childcare if you’re working"
assert_rendered_outcome text: "Check if you’re eligible for free childcare if you're working"
end
end

should "render Winter Fuel Payment" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,30 +670,62 @@ class CheckBenefitsFinancialSupportCalculatorTest < ActiveSupport::TestCase
end
end

context "#eligible_for_30hrs_free_childcare_3_4yrs?" do
context "#eligible_for_free_childcare_when_working_1_under_2_3_4yrs?" do
context "when eligible" do
should "be true if working, with child aged 3 to 4" do
@calculator.are_you_working = "yes"
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "3_to_4"
assert @calculator.eligible_for_30hrs_free_childcare_3_4yrs?
assert @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end

should "be true if working, with child aged 1 or under" do
@calculator.are_you_working = "yes"
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "1_or_under"
assert @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end

should "be true if working, with child aged 2" do
@calculator.are_you_working = "yes"
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "2"
assert @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end
end

context "when ineligible" do
should "be false if working, with child not aged 3 to 4" do
should "be false if working, with child not aged under 1, 2 or 3 to 4" do
@calculator.are_you_working = "yes"
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "1,5_to_7"
assert_not @calculator.eligible_for_30hrs_free_childcare_3_4yrs?
@calculator.age_of_children = "5_to_7"
assert_not @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end

should "be false if not working, with child aged 3 to 4" do
%w[no no_retired].each do |working|
@calculator.are_you_working = working
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "3_to_4"
assert_not @calculator.eligible_for_30hrs_free_childcare_3_4yrs?
assert_not @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end
end

should "be false if not working, with child aged 1 and under" do
%w[no no_retired].each do |working|
@calculator.are_you_working = working
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "1_or_under"
assert_not @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end
end

should "be false if not working, with child aged 2" do
%w[no no_retired].each do |working|
@calculator.are_you_working = working
@calculator.children_living_with_you = "yes"
@calculator.age_of_children = "2"
assert_not @calculator.eligible_for_free_childcare_when_working_1_under_2_3_4yrs?
end
end
end
Expand Down

0 comments on commit 81ceb3d

Please sign in to comment.