From ccf2846de607033221ea2566d4cb089ab1d434c5 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 14:27:42 +0100
Subject: [PATCH 01/44] Add script to generate permitted next nodes for all
 flows

I'm about to change all the flows to use the  mechanism for automatically
detecting permitted next nodes. Although the existing tests, particularly
the regression tests should give a lot of confidence that nothing gets
broken, I'm hoping to compare the results of this script before and after
the changes as a double-check.
---
 script/generate-permitted-next-nodes-for-all-flows.rb | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 script/generate-permitted-next-nodes-for-all-flows.rb

diff --git a/script/generate-permitted-next-nodes-for-all-flows.rb b/script/generate-permitted-next-nodes-for-all-flows.rb
new file mode 100644
index 00000000000..77134376d64
--- /dev/null
+++ b/script/generate-permitted-next-nodes-for-all-flows.rb
@@ -0,0 +1,11 @@
+flows = SmartAnswer::FlowRegistry.instance.flows
+data = flows.sort_by(&:name).inject({}) do |hash, flow|
+  hash[flow.name] = flow.questions.sort_by(&:name).inject({}) do |q_vs_pnn, question|
+    q_vs_pnn[question.name] = question.permitted_next_nodes.sort
+    q_vs_pnn
+  end
+  hash
+end
+
+path = Rails.root.join('test', 'data', 'permitted-next-nodes.yml')
+File.write(path, data.to_yaml)

From 97dcf5ddbc900a1a2ae169b7ec38b866038668bf Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 14:31:42 +0100
Subject: [PATCH 02/44] Generate permitted next node YAML for all flows

I ran the following command:

    $ rails r script/generate-permitted-next-nodes-for-all-flows.rb
---
 test/data/permitted-next-nodes.yml | 1557 ++++++++++++++++++++++++++++
 1 file changed, 1557 insertions(+)
 create mode 100644 test/data/permitted-next-nodes.yml

diff --git a/test/data/permitted-next-nodes.yml b/test/data/permitted-next-nodes.yml
new file mode 100644
index 00000000000..9c35dad844e
--- /dev/null
+++ b/test/data/permitted-next-nodes.yml
@@ -0,0 +1,1557 @@
+---
+additional-commodity-code:
+  :how_much_milk_fat?:
+  - :commodity_code_result
+  - :how_much_milk_protein_ab?
+  - :how_much_milk_protein_c?
+  - :how_much_milk_protein_d?
+  - :how_much_milk_protein_ef?
+  - :how_much_milk_protein_gh?
+  :how_much_milk_protein_ab?:
+  - :commodity_code_result
+  :how_much_milk_protein_c?:
+  - :commodity_code_result
+  :how_much_milk_protein_d?:
+  - :commodity_code_result
+  :how_much_milk_protein_ef?:
+  - :commodity_code_result
+  :how_much_milk_protein_gh?:
+  - :commodity_code_result
+  :how_much_starch_glucose?:
+  - :how_much_sucrose_1?
+  - :how_much_sucrose_2?
+  - :how_much_sucrose_3?
+  - :how_much_sucrose_4?
+  :how_much_sucrose_1?:
+  - :how_much_milk_fat?
+  :how_much_sucrose_2?:
+  - :how_much_milk_fat?
+  :how_much_sucrose_3?:
+  - :how_much_milk_fat?
+  :how_much_sucrose_4?:
+  - :how_much_milk_fat?
+am-i-getting-minimum-wage:
+  :are_you_an_apprentice?:
+  - :how_often_do_you_get_paid?
+  - :how_old_are_you?
+  :current_accommodation_charge?:
+  - :current_accommodation_usage?
+  :current_accommodation_usage?:
+  - :current_payment_above
+  - :current_payment_below
+  :how_many_hours_did_you_work?:
+  - :how_much_were_you_paid_during_pay_period?
+  :how_many_hours_do_you_work?:
+  - :how_much_are_you_paid_during_pay_period?
+  :how_many_hours_overtime_did_you_work?:
+  - :was_provided_with_accommodation?
+  - :what_was_overtime_pay_per_hour?
+  :how_many_hours_overtime_do_you_work?:
+  - :is_provided_with_accommodation?
+  - :what_is_overtime_pay_per_hour?
+  :how_much_are_you_paid_during_pay_period?:
+  - :how_many_hours_overtime_do_you_work?
+  :how_much_were_you_paid_during_pay_period?:
+  - :how_many_hours_overtime_did_you_work?
+  :how_often_did_you_get_paid?:
+  - :how_many_hours_did_you_work?
+  :how_often_do_you_get_paid?:
+  - :how_many_hours_do_you_work?
+  :how_old_are_you?:
+  - :how_often_do_you_get_paid?
+  - :under_school_leaving_age
+  :how_old_were_you?:
+  - :how_often_did_you_get_paid?
+  - :under_school_leaving_age_past
+  :is_provided_with_accommodation?:
+  - :current_accommodation_charge?
+  - :current_accommodation_usage?
+  - :current_payment_above
+  - :current_payment_below
+  :past_accommodation_charge?:
+  - :past_accommodation_usage?
+  :past_accommodation_usage?:
+  - :past_payment_above
+  - :past_payment_below
+  :past_payment_date?:
+  - :were_you_an_apprentice?
+  :was_provided_with_accommodation?:
+  - :past_accommodation_charge?
+  - :past_accommodation_usage?
+  - :past_payment_above
+  - :past_payment_below
+  :were_you_an_apprentice?:
+  - :does_not_apply_to_historical_apprentices
+  - :how_often_did_you_get_paid?
+  - :how_old_were_you?
+  :what_is_overtime_pay_per_hour?:
+  - :is_provided_with_accommodation?
+  :what_was_overtime_pay_per_hour?:
+  - :was_provided_with_accommodation?
+  :what_would_you_like_to_check?:
+  - :are_you_an_apprentice?
+  - :past_payment_date?
+  - :will_you_be_a_first_year_apprentice?
+  :will_you_be_a_first_year_apprentice?:
+  - :does_not_apply_to_first_year_apprentices
+  - :how_old_are_you?
+benefit-cap-calculator:
+  :bereavement_amount?:
+  - :carers_amount?
+  - :child_benefit_amount?
+  - :child_tax_amount?
+  - :esa_amount?
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :carers_amount?:
+  - :child_benefit_amount?
+  - :child_tax_amount?
+  - :esa_amount?
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :child_benefit_amount?:
+  - :child_tax_amount?
+  - :esa_amount?
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :child_tax_amount?:
+  - :esa_amount?
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :esa_amount?:
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :guardian_amount?:
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :housing_benefit_amount?:
+  - :single_couple_lone_parent?
+  :incapacity_amount?:
+  - :housing_benefit_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :income_support_amount?:
+  - :housing_benefit_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :jsa_amount?:
+  - :housing_benefit_amount?
+  - :maternity_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :maternity_amount?:
+  - :housing_benefit_amount?
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :receive_housing_benefit?:
+  - :outcome_not_affected_no_housing_benefit
+  - :working_tax_credit?
+  :receiving_exemption_benefits?:
+  - :outcome_not_affected_exemptions
+  - :receiving_non_exemption_benefits?
+  :receiving_non_exemption_benefits?:
+  - :bereavement_amount?
+  - :carers_amount?
+  - :child_benefit_amount?
+  - :child_tax_amount?
+  - :esa_amount?
+  - :guardian_amount?
+  - :housing_benefit_amount?
+  - :incapacity_amount?
+  - :income_support_amount?
+  - :jsa_amount?
+  - :maternity_amount?
+  - :outcome_not_affected
+  - :sda_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :sda_amount?:
+  - :housing_benefit_amount?
+  - :single_couple_lone_parent?
+  - :widow_pension_amount?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :single_couple_lone_parent?:
+  - :outcome_affected_greater_than_cap
+  - :outcome_not_affected_less_than_cap
+  :widow_pension_amount?:
+  - :housing_benefit_amount?
+  - :single_couple_lone_parent?
+  - :widowed_mother_amount?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :widowed_mother_amount?:
+  - :housing_benefit_amount?
+  - :single_couple_lone_parent?
+  - :widowed_parent_amount?
+  - :widows_aged_amount?
+  :widowed_parent_amount?:
+  - :housing_benefit_amount?
+  - :single_couple_lone_parent?
+  - :widows_aged_amount?
+  :widows_aged_amount?:
+  - :housing_benefit_amount?
+  - :single_couple_lone_parent?
+  :working_tax_credit?:
+  - :outcome_not_affected_exemptions
+  - :receiving_exemption_benefits?
+calculate-agricultural-holiday-entitlement:
+  :how_many_days_per_week?:
+  - :worked_for_same_employer?
+  :how_many_total_days?:
+  - :worked_for_same_employer?
+  :how_many_weeks_at_current_employer?:
+  - :done
+  :what_date_does_holiday_start?:
+  - :how_many_total_days?
+  :work_the_same_number_of_days_each_week?:
+  - :how_many_days_per_week?
+  - :what_date_does_holiday_start?
+  :worked_for_same_employer?:
+  - :done
+  - :how_many_weeks_at_current_employer?
+calculate-employee-redundancy-pay:
+  :age_of_employee?:
+  - :years_employed?
+  :date_of_redundancy?:
+  - :age_of_employee?
+  :weekly_pay_before_tax?:
+  - :done
+  - :done_no_statutory
+  :years_employed?:
+  - :done_no_statutory
+  - :weekly_pay_before_tax?
+calculate-married-couples-allowance:
+  :did_you_marry_or_civil_partner_before_5_december_2005?:
+  - :whats_the_highest_earners_date_of_birth?
+  - :whats_the_husbands_date_of_birth?
+  :how_much_expected_contributions_before_tax?:
+  - :how_much_expected_contributions_with_tax_relief?
+  :how_much_expected_contributions_with_tax_relief?:
+  - :how_much_expected_gift_aided_donations?
+  :how_much_expected_gift_aided_donations?:
+  - :highest_earner_done
+  - :husband_done
+  :paying_into_a_pension?:
+  - :how_much_expected_contributions_before_tax?
+  - :how_much_expected_gift_aided_donations?
+  :were_you_or_your_partner_born_on_or_before_6_april_1935?:
+  - :did_you_marry_or_civil_partner_before_5_december_2005?
+  - :sorry
+  :whats_the_highest_earners_date_of_birth?:
+  - :whats_the_highest_earners_income?
+  :whats_the_highest_earners_income?:
+  - :highest_earner_done
+  - :paying_into_a_pension?
+  :whats_the_husbands_date_of_birth?:
+  - :whats_the_husbands_income?
+  :whats_the_husbands_income?:
+  - :husband_done
+  - :paying_into_a_pension?
+calculate-statutory-sick-pay:
+  :contractual_days_covered_by_earnings?:
+  - :usual_work_days?
+  :days_covered_by_earnings?:
+  - :usual_work_days?
+  :employee_tell_within_limit?:
+  - :employee_work_different_days?
+  :employee_work_different_days?:
+  - :first_sick_day?
+  - :not_regular_schedule
+  :first_sick_day?:
+  - :last_sick_day?
+  :has_linked_sickness?:
+  - :linked_sickness_start_date?
+  - :paid_at_least_8_weeks?
+  :how_often_pay_employee_pay_patterns?:
+  - :last_payday_before_sickness?
+  - :pay_amount_if_not_sick?
+  :is_your_employee_getting?:
+  - :already_getting_maternity
+  - :employee_tell_within_limit?
+  :last_payday_before_offset?:
+  - :total_employee_earnings?
+  :last_payday_before_sickness?:
+  - :last_payday_before_offset?
+  :last_sick_day?:
+  - :has_linked_sickness?
+  - :must_be_sick_for_4_days
+  :linked_sickness_end_date?:
+  - :paid_at_least_8_weeks?
+  :linked_sickness_start_date?:
+  - :linked_sickness_end_date?
+  :paid_at_least_8_weeks?:
+  - :how_often_pay_employee_pay_patterns?
+  - :total_earnings_before_sick_period?
+  :pay_amount_if_not_sick?:
+  - :contractual_days_covered_by_earnings?
+  :total_earnings_before_sick_period?:
+  - :days_covered_by_earnings?
+  :total_employee_earnings?:
+  - :usual_work_days?
+  :usual_work_days?:
+  - :entitled_to_sick_pay
+  - :maximum_entitlement_reached
+  - :not_earned_enough
+  - :not_entitled_3_days_not_paid
+calculate-your-child-maintenance:
+  :are_you_paying_or_receiving?:
+  - :how_many_children_paid_for?
+  :gets_benefits?:
+  - :gross_income_of_payee?
+  - :how_many_nights_children_stay_with_payee?
+  :gross_income_of_payee?:
+  - :flat_rate_result
+  - :how_many_other_children_in_payees_household?
+  - :nil_rate_result
+  :how_many_children_paid_for?:
+  - :gets_benefits?
+  :how_many_nights_children_stay_with_payee?:
+  - :flat_rate_result
+  - :nil_rate_result
+  - :reduced_and_basic_rates_result
+  :how_many_other_children_in_payees_household?:
+  - :how_many_nights_children_stay_with_payee?
+calculate-your-holiday-entitlement:
+  :annualised_hours?:
+  - :annualised_hours_done
+  :basis_of_calculation?:
+  - :annualised_hours?
+  - :calculation_period?
+  - :casual_or_irregular_hours?
+  - :compressed_hours_how_many_hours_per_week?
+  - :shift_worker_basis?
+  :calculation_period?:
+  - :how_many_days_per_week?
+  - :how_many_hours_per_week?
+  - :what_is_your_leaving_date?
+  - :what_is_your_starting_date?
+  :casual_or_irregular_hours?:
+  - :casual_or_irregular_hours_done
+  :compressed_hours_how_many_days_per_week?:
+  - :compressed_hours_done
+  :compressed_hours_how_many_hours_per_week?:
+  - :compressed_hours_how_many_days_per_week?
+  :how_many_days_per_week?:
+  - :days_per_week_done
+  :how_many_hours_per_week?:
+  - :hours_per_week_done
+  :shift_worker_basis?:
+  - :shift_worker_hours_per_shift?
+  - :what_is_your_leaving_date?
+  - :what_is_your_starting_date?
+  :shift_worker_days_per_shift_pattern?:
+  - :shift_worker_done
+  :shift_worker_hours_per_shift?:
+  - :shift_worker_shifts_per_shift_pattern?
+  :shift_worker_shifts_per_shift_pattern?:
+  - :shift_worker_days_per_shift_pattern?
+  :what_is_your_leaving_date?:
+  - :how_many_days_per_week?
+  - :how_many_hours_per_week?
+  - :shift_worker_hours_per_shift?
+  - :when_does_your_leave_year_start?
+  :what_is_your_starting_date?:
+  - :what_is_your_leaving_date?
+  - :when_does_your_leave_year_start?
+  :when_does_your_leave_year_start?:
+  - :how_many_days_per_week?
+  - :how_many_hours_per_week?
+  - :shift_worker_hours_per_shift?
+calculate-your-redundancy-pay:
+  :age_of_employee?:
+  - :years_employed?
+  :date_of_redundancy?:
+  - :age_of_employee?
+  :weekly_pay_before_tax?:
+  - :done
+  - :done_no_statutory
+  :years_employed?:
+  - :done_no_statutory
+  - :weekly_pay_before_tax?
+check-uk-visa:
+  :israeli_document_type?:
+  - :purpose_of_visit?
+  :passing_through_uk_border_control?:
+  - :outcome_no_visa_needed
+  - :outcome_transit_leaving_airport
+  - :outcome_transit_leaving_airport_datv
+  - :outcome_transit_not_leaving_airport
+  - :outcome_transit_refugee_not_leaving_airport
+  - :outcome_transit_taiwan
+  - :outcome_transit_taiwan_through_border_control
+  - :outcome_transit_venezuela
+  :purpose_of_visit?:
+  - :outcome_diplomatic_business
+  - :outcome_joining_family_m
+  - :outcome_joining_family_nvn
+  - :outcome_joining_family_y
+  - :outcome_marriage
+  - :outcome_medical_n
+  - :outcome_medical_y
+  - :outcome_no_visa_needed
+  - :outcome_school_n
+  - :outcome_school_waiver
+  - :outcome_school_y
+  - :outcome_standard_visit
+  - :outcome_taiwan_exception
+  - :outcome_visit_waiver
+  - :passing_through_uk_border_control?
+  - :staying_for_how_long?
+  :staying_for_how_long?:
+  - :outcome_no_visa_needed
+  - :outcome_study_m
+  - :outcome_study_waiver
+  - :outcome_study_y
+  - :outcome_taiwan_exception
+  - :outcome_work_m
+  - :outcome_work_n
+  - :outcome_work_waiver
+  - :outcome_work_y
+  :what_passport_do_you_have?:
+  - :israeli_document_type?
+  - :outcome_no_visa_needed
+  - :purpose_of_visit?
+childcare-costs-for-tax-credits:
+  :currently_claiming?:
+  - :have_costs_changed?
+  - :how_often_use_childcare?
+  :have_costs_changed?:
+  - :how_often_pay_2?
+  - :no_change
+  :how_much_12_months_1?:
+  - :weekly_costs_are_x
+  :how_much_12_months_2?:
+  - :no_longer_paying
+  - :old_weekly_amount_1?
+  :how_much_4_weeks?:
+  - :weekly_costs_are_x
+  :how_much_52_weeks_1?:
+  - :weekly_costs_are_x
+  :how_much_52_weeks_2?:
+  - :no_longer_paying
+  - :old_weekly_amount_1?
+  :how_much_each_month?:
+  - :weekly_costs_are_x
+  :how_much_fortnightly?:
+  - :weekly_costs_are_x
+  :how_much_spent_last_12_months?:
+  - :weekly_costs_are_x
+  :how_much_yearly?:
+  - :weekly_costs_are_x
+  :how_often_pay_1?:
+  - :how_much_12_months_1?
+  - :how_much_52_weeks_1?
+  - :how_much_each_month?
+  - :round_up_weekly
+  :how_often_pay_2?:
+  - :how_much_12_months_2?
+  - :how_much_52_weeks_2?
+  - :new_monthly_cost?
+  - :new_weekly_costs?
+  :how_often_pay_providers?:
+  - :call_helpline_plain
+  - :how_much_4_weeks?
+  - :how_much_each_month?
+  - :how_much_fortnightly?
+  - :how_much_yearly?
+  - :round_up_weekly
+  :how_often_use_childcare?:
+  - :call_helpline_detailed
+  - :how_often_pay_1?
+  - :pay_same_each_time?
+  :new_monthly_cost?:
+  - :no_longer_paying
+  - :old_weekly_amount_3?
+  :new_weekly_costs?:
+  - :no_longer_paying
+  - :old_weekly_amount_2?
+  :old_weekly_amount_1?:
+  - :cost_changed
+  :old_weekly_amount_2?:
+  - :cost_changed
+  :old_weekly_amount_3?:
+  - :cost_changed
+  :pay_same_each_time?:
+  - :how_much_spent_last_12_months?
+  - :how_often_pay_providers?
+energy-grants-calculator:
+  :date_of_birth?:
+  - :outcome_help_with_bills
+  - :when_property_built?
+  - :which_benefits?
+  :disabled_or_have_children?:
+  - :outcome_help_with_bills
+  - :when_property_built?
+  :home_features_historic?:
+  - :outcome_bills_and_measures_no_benefits
+  - :outcome_bills_and_measures_on_benefits_eco_eligible
+  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
+  - :outcome_measures_help_green_deal
+  :home_features_modern?:
+  - :outcome_bills_and_measures_no_benefits
+  - :outcome_bills_and_measures_on_benefits_eco_eligible
+  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
+  - :outcome_measures_help_green_deal
+  - :outcome_no_green_deal_no_energy_measures
+  :home_features_older?:
+  - :outcome_bills_and_measures_no_benefits
+  - :outcome_bills_and_measures_on_benefits_eco_eligible
+  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
+  - :outcome_measures_help_green_deal
+  :type_of_flat?:
+  - :home_features_historic?
+  - :home_features_modern?
+  - :home_features_older?
+  :type_of_property?:
+  - :home_features_historic?
+  - :home_features_modern?
+  - :home_features_older?
+  - :type_of_flat?
+  :what_are_you_looking_for?:
+  - :what_are_your_circumstances?
+  - :what_are_your_circumstances_without_bills_help?
+  :what_are_your_circumstances?:
+  - :date_of_birth?
+  :what_are_your_circumstances_without_bills_help?:
+  - :date_of_birth?
+  - :when_property_built?
+  - :which_benefits?
+  :when_property_built?:
+  - :type_of_property?
+  :which_benefits?:
+  - :disabled_or_have_children?
+  - :outcome_help_with_bills
+  - :when_property_built?
+estimate-self-assessment-penalties:
+  :how_much_tax?:
+  - :late
+  :how_submitted?:
+  - :when_submitted?
+  :when_paid?:
+  - :filed_and_paid_on_time
+  - :how_much_tax?
+  :when_submitted?:
+  - :when_paid?
+  :which_year?:
+  - :how_submitted?
+help-if-you-are-arrested-abroad:
+  :which_country?:
+  - :answer_one_generic
+  - :answer_three_syria
+  - :answer_two_iran
+inherits-someone-dies-without-will:
+  :aunts_or_uncles?:
+  - :grandparents?
+  - :half_aunts_or_uncles?
+  - :outcome_6
+  - :outcome_67
+  :children?:
+  - :more_than_one_child?
+  - :outcome_1
+  - :outcome_2
+  - :outcome_20
+  - :outcome_40
+  - :outcome_66
+  - :parents?
+  :estate_over_250000?:
+  - :children?
+  - :outcome_1
+  - :outcome_60
+  :grandparents?:
+  - :aunts_or_uncles?
+  - :great_aunts_or_uncles?
+  - :outcome_5
+  :great_aunts_or_uncles?:
+  - :outcome_45
+  - :outcome_46
+  :half_aunts_or_uncles?:
+  - :outcome_24
+  - :outcome_25
+  :half_siblings?:
+  - :grandparents?
+  - :outcome_23
+  :more_than_one_child?:
+  - :outcome_61
+  - :outcome_62
+  :parents?:
+  - :outcome_3
+  - :outcome_63
+  - :siblings?
+  - :siblings_including_mixed_parents?
+  :partner?:
+  - :children?
+  - :estate_over_250000?
+  :region?:
+  - :partner?
+  :siblings?:
+  - :aunts_or_uncles?
+  - :grandparents?
+  - :half_siblings?
+  - :outcome_1
+  - :outcome_3
+  - :outcome_4
+  - :outcome_41
+  - :outcome_42
+  - :outcome_43
+  - :outcome_44
+  :siblings_including_mixed_parents?:
+  - :outcome_64
+  - :outcome_65
+landlord-immigration-check:
+  :has_asylum_card?:
+  - :immigration_application?
+  - :outcome_can_rent_for_12_months
+  :has_certificate?:
+  - :outcome_can_rent
+  - :tenant_country?
+  :has_documents?:
+  - :has_other_documents?
+  - :outcome_can_rent
+  :has_other_documents?:
+  - :outcome_can_rent
+  - :time_limited_to_remain?
+  :has_residence_card_or_eu_eea_swiss_family_member?:
+  - :has_asylum_card?
+  - :outcome_can_rent
+  :has_uk_passport?:
+  - :outcome_can_rent
+  - :right_to_abode?
+  :immigration_application?:
+  - :outcome_can_not_rent
+  - :outcome_can_rent_for_12_months
+  :main_home?:
+  - :property_type?
+  - :tenant_over_18?
+  :property?:
+  - :main_home?
+  - :outcome_check_not_needed
+  :property_type?:
+  - :outcome_check_may_be_needed_when_student
+  - :outcome_check_needed_if_break_clause
+  - :outcome_check_not_needed
+  - :outcome_check_not_needed_if_holiday_or_under_3_months
+  - :outcome_check_not_needed_when_care_home
+  - :outcome_check_not_needed_when_employee_home
+  - :outcome_check_not_needed_when_hostel_refuge
+  - :outcome_check_not_needed_when_mobile_home
+  :right_to_abode?:
+  - :has_certificate?
+  - :outcome_can_rent
+  :tenant_country?:
+  - :has_documents?
+  - :has_other_documents?
+  - :has_residence_card_or_eu_eea_swiss_family_member?
+  :tenant_over_18?:
+  - :has_uk_passport?
+  - :outcome_check_not_needed_when_under_18
+  :time_limited_to_remain?:
+  - :has_residence_card_or_eu_eea_swiss_family_member?
+  - :outcome_can_rent_but_check_will_be_needed_again
+legalisation-document-checker:
+  :which_documents_do_you_want_legalised?:
+  - :outcome_results
+marriage-abroad:
+  :country_of_ceremony?:
+  - :legal_residency?
+  - :marriage_or_pacs?
+  - :outcome_os_france_or_fot
+  - :partner_opposite_or_same_sex?
+  :legal_residency?:
+  - :partner_opposite_or_same_sex?
+  - :what_is_your_partners_nationality?
+  :marriage_or_pacs?:
+  - :outcome_cp_france_pacs
+  - :outcome_monaco
+  - :outcome_os_france_or_fot
+  :partner_opposite_or_same_sex?:
+  - :outcome_brazil_not_living_in_the_uk
+  - :outcome_consular_cni_os_residing_in_third_country
+  - :outcome_cp_all_other_countries
+  - :outcome_cp_commonwealth_countries
+  - :outcome_cp_consular
+  - :outcome_cp_no_cni
+  - :outcome_cp_or_equivalent
+  - :outcome_ireland
+  - :outcome_marriage_via_local_authorities
+  - :outcome_os_affirmation
+  - :outcome_os_belarus
+  - :outcome_os_bot
+  - :outcome_os_cambodia
+  - :outcome_os_colombia
+  - :outcome_os_commonwealth
+  - :outcome_os_consular_cni
+  - :outcome_os_germany
+  - :outcome_os_hong_kong
+  - :outcome_os_indonesia
+  - :outcome_os_italy
+  - :outcome_os_japan
+  - :outcome_os_kosovo
+  - :outcome_os_kuwait
+  - :outcome_os_laos
+  - :outcome_os_marriage_impossible_no_laos_locals
+  - :outcome_os_no_cni
+  - :outcome_os_oman
+  - :outcome_os_other_countries
+  - :outcome_os_poland
+  - :outcome_os_slovenia
+  - :outcome_portugal
+  - :outcome_spain
+  - :outcome_ss_affirmation
+  - :outcome_ss_marriage
+  - :outcome_ss_marriage_malta
+  - :outcome_ss_marriage_not_possible
+  - :outcome_switzerland
+  :what_is_your_partners_nationality?:
+  - :partner_opposite_or_same_sex?
+maternity-paternity-calculator:
+  :adoption_date_leave_starts?:
+  - :adoption_leave_and_pay
+  - :last_normal_payday_adoption?
+  :adoption_did_the_employee_work_for_you?:
+  - :adoption_employment_contract?
+  - :adoption_not_entitled_to_leave_or_pay
+  :adoption_employment_contract?:
+  - :adoption_is_the_employee_on_your_payroll?
+  :adoption_is_the_employee_on_your_payroll?:
+  - :adoption_date_leave_starts?
+  - :adoption_not_entitled_to_leave_or_pay
+  :baby_birth_date_paternity?:
+  - :employee_responsible_for_upbringing?
+  :baby_due_date_maternity?:
+  - :employment_contract?
+  :baby_due_date_paternity?:
+  - :baby_birth_date_paternity?
+  :date_leave_starts?:
+  - :did_the_employee_work_for_you?
+  :date_of_adoption_match?:
+  - :date_of_adoption_placement?
+  :date_of_adoption_placement?:
+  - :adoption_did_the_employee_work_for_you?
+  :day_of_the_month_paternity?:
+  - :pay_date_options_paternity?
+  :days_of_the_week_paternity?:
+  - :adoption_leave_and_pay
+  - :paternity_leave_and_pay
+  :did_the_employee_work_for_you?:
+  - :is_the_employee_on_your_payroll?
+  - :maternity_leave_and_pay_result
+  :earnings_for_pay_period?:
+  - :how_do_you_want_the_smp_calculated?
+  :earnings_for_pay_period_adoption?:
+  - :adoption_leave_and_pay
+  - :how_do_you_want_the_sap_calculated?
+  :earnings_for_pay_period_paternity?:
+  - :how_do_you_want_the_spp_calculated?
+  - :paternity_leave_and_pay
+  :employee_date_matched_paternity_adoption?:
+  - :padoption_date_of_adoption_placement?
+  :employee_has_contract_paternity?:
+  - :employee_on_payroll_paternity?
+  :employee_on_payroll_paternity?:
+  - :employee_start_paternity?
+  - :employee_still_employed_on_birth_date?
+  - :paternity_not_entitled_to_leave_or_pay
+  :employee_paternity_length?:
+  - :last_normal_payday_paternity?
+  - :paternity_not_entitled_to_leave_or_pay
+  :employee_responsible_for_upbringing?:
+  - :employee_work_before_employment_start?
+  - :paternity_not_entitled_to_leave_or_pay
+  :employee_start_paternity?:
+  - :employee_paternity_length?
+  :employee_still_employed_on_birth_date?:
+  - :employee_start_paternity?
+  - :paternity_not_entitled_to_leave_or_pay
+  :employee_work_before_employment_start?:
+  - :employee_has_contract_paternity?
+  - :paternity_not_entitled_to_leave_or_pay
+  :employment_contract?:
+  - :date_leave_starts?
+  :how_do_you_want_the_sap_calculated?:
+  - :adoption_leave_and_pay
+  - :monthly_pay_paternity?
+  - :next_pay_day_paternity?
+  :how_do_you_want_the_smp_calculated?:
+  - :maternity_leave_and_pay_result
+  - :when_in_the_month_is_the_employee_paid?
+  - :when_is_your_employees_next_pay_day?
+  :how_do_you_want_the_spp_calculated?:
+  - :monthly_pay_paternity?
+  - :next_pay_day_paternity?
+  - :paternity_leave_and_pay
+  :is_the_employee_on_your_payroll?:
+  - :last_normal_payday?
+  - :maternity_leave_and_pay_result
+  :last_normal_payday?:
+  - :payday_eight_weeks?
+  :last_normal_payday_adoption?:
+  - :payday_eight_weeks_adoption?
+  :last_normal_payday_paternity?:
+  - :payday_eight_weeks_paternity?
+  :leave_or_pay_for_adoption?:
+  - :baby_due_date_paternity?
+  - :employee_date_matched_paternity_adoption?
+  :monthly_pay_paternity?:
+  - :adoption_leave_and_pay
+  - :day_of_the_month_paternity?
+  - :days_of_the_week_paternity?
+  - :paternity_leave_and_pay
+  - :specific_date_each_month_paternity?
+  :next_pay_day_paternity?:
+  - :paternity_leave_and_pay
+  :padoption_date_of_adoption_placement?:
+  - :padoption_employee_responsible_for_upbringing?
+  :padoption_employee_responsible_for_upbringing?:
+  - :employee_work_before_employment_start?
+  - :paternity_not_entitled_to_leave_or_pay
+  :pay_date_options_paternity?:
+  - :adoption_leave_and_pay
+  - :paternity_leave_and_pay
+  :pay_frequency?:
+  - :earnings_for_pay_period?
+  :pay_frequency_adoption?:
+  - :earnings_for_pay_period_adoption?
+  :pay_frequency_paternity?:
+  - :earnings_for_pay_period_paternity?
+  :payday_eight_weeks?:
+  - :pay_frequency?
+  :payday_eight_weeks_adoption?:
+  - :pay_frequency_adoption?
+  :payday_eight_weeks_paternity?:
+  - :pay_frequency_paternity?
+  :specific_date_each_month_paternity?:
+  - :adoption_leave_and_pay
+  - :paternity_leave_and_pay
+  :taking_paternity_leave_for_adoption?:
+  - :date_of_adoption_match?
+  - :employee_date_matched_paternity_adoption?
+  :what_days_does_the_employee_work?:
+  - :maternity_leave_and_pay_result
+  :what_particular_day_of_the_month_is_the_employee_paid?:
+  - :which_week_in_month_is_the_employee_paid?
+  :what_specific_date_each_month_is_the_employee_paid?:
+  - :maternity_leave_and_pay_result
+  :what_type_of_leave?:
+  - :baby_due_date_maternity?
+  - :leave_or_pay_for_adoption?
+  - :taking_paternity_leave_for_adoption?
+  :when_in_the_month_is_the_employee_paid?:
+  - :maternity_leave_and_pay_result
+  - :what_days_does_the_employee_work?
+  - :what_particular_day_of_the_month_is_the_employee_paid?
+  - :what_specific_date_each_month_is_the_employee_paid?
+  :when_is_your_employees_next_pay_day?:
+  - :maternity_leave_and_pay_result
+  :which_week_in_month_is_the_employee_paid?:
+  - :maternity_leave_and_pay_result
+minimum-wage-calculator-employers:
+  :are_you_an_apprentice?:
+  - :how_often_do_you_get_paid?
+  - :how_old_are_you?
+  :current_accommodation_charge?:
+  - :current_accommodation_usage?
+  :current_accommodation_usage?:
+  - :current_payment_above
+  - :current_payment_below
+  :how_many_hours_did_you_work?:
+  - :how_much_were_you_paid_during_pay_period?
+  :how_many_hours_do_you_work?:
+  - :how_much_are_you_paid_during_pay_period?
+  :how_many_hours_overtime_did_you_work?:
+  - :was_provided_with_accommodation?
+  - :what_was_overtime_pay_per_hour?
+  :how_many_hours_overtime_do_you_work?:
+  - :is_provided_with_accommodation?
+  - :what_is_overtime_pay_per_hour?
+  :how_much_are_you_paid_during_pay_period?:
+  - :how_many_hours_overtime_do_you_work?
+  :how_much_were_you_paid_during_pay_period?:
+  - :how_many_hours_overtime_did_you_work?
+  :how_often_did_you_get_paid?:
+  - :how_many_hours_did_you_work?
+  :how_often_do_you_get_paid?:
+  - :how_many_hours_do_you_work?
+  :how_old_are_you?:
+  - :how_often_do_you_get_paid?
+  - :under_school_leaving_age
+  :how_old_were_you?:
+  - :how_often_did_you_get_paid?
+  - :under_school_leaving_age_past
+  :is_provided_with_accommodation?:
+  - :current_accommodation_charge?
+  - :current_accommodation_usage?
+  - :current_payment_above
+  - :current_payment_below
+  :past_accommodation_charge?:
+  - :past_accommodation_usage?
+  :past_accommodation_usage?:
+  - :past_payment_above
+  - :past_payment_below
+  :past_payment_date?:
+  - :were_you_an_apprentice?
+  :was_provided_with_accommodation?:
+  - :past_accommodation_charge?
+  - :past_accommodation_usage?
+  - :past_payment_above
+  - :past_payment_below
+  :were_you_an_apprentice?:
+  - :does_not_apply_to_historical_apprentices
+  - :how_often_did_you_get_paid?
+  - :how_old_were_you?
+  :what_is_overtime_pay_per_hour?:
+  - :is_provided_with_accommodation?
+  :what_was_overtime_pay_per_hour?:
+  - :was_provided_with_accommodation?
+  :what_would_you_like_to_check?:
+  - :are_you_an_apprentice?
+  - :past_payment_date?
+overseas-passports:
+  :child_or_adult_passport?:
+  - :country_of_birth?
+  - :ips_application_result
+  - :ips_application_result_online
+  :country_of_birth?:
+  - :ips_application_result
+  - :ips_application_result_online
+  :renewing_replacing_applying?:
+  - :child_or_adult_passport?
+  :which_country_are_you_in?:
+  - :apply_in_neighbouring_country
+  - :cannot_apply
+  - :renewing_replacing_applying?
+  - :which_opt?
+  :which_opt?:
+  - :renewing_replacing_applying?
+part-year-profit-tax-credits:
+  :did_you_start_trading_before_the_relevant_accounting_year?:
+  - :when_did_you_start_trading?
+  - :when_did_you_stop_trading?
+  :do_your_accounts_cover_a_12_month_period?:
+  - :what_is_your_taxable_profit?
+  - :when_did_you_start_trading?
+  :have_you_stopped_trading?:
+  - :did_you_start_trading_before_the_relevant_accounting_year?
+  - :do_your_accounts_cover_a_12_month_period?
+  :what_date_do_your_accounts_go_up_to?:
+  - :have_you_stopped_trading?
+  :what_is_your_taxable_profit?:
+  - :result
+  :when_did_you_start_trading?:
+  - :what_is_your_taxable_profit?
+  - :when_did_you_stop_trading?
+  :when_did_you_stop_trading?:
+  - :what_is_your_taxable_profit?
+  :when_did_your_tax_credits_award_end?:
+  - :what_date_do_your_accounts_go_up_to?
+pay-leave-for-parents:
+  :due_date:
+  - :employment_status_of_mother
+  :employment_status_of_mother:
+  - :employment_status_of_partner
+  - :mother_started_working_before_continuity_start_date
+  - :mother_worked_at_least_26_weeks
+  :employment_status_of_partner:
+  - :mother_started_working_before_continuity_start_date
+  - :mother_worked_at_least_26_weeks
+  :mother_earned_at_least_390:
+  - :outcome_birth_nothing
+  - :outcome_mat_allowance_14_weeks
+  - :outcome_mat_leave
+  - :outcome_single_birth_nothing
+  - :partner_started_working_before_continuity_start_date
+  - :partner_worked_at_least_26_weeks
+  - :salary_1_66_weeks
+  :mother_earned_more_than_lower_earnings_limit:
+  - :mother_worked_at_least_26_weeks
+  - :outcome_mat_leave_mat_pay
+  - :outcome_mat_pay
+  - :partner_started_working_before_continuity_start_date
+  - :partner_worked_at_least_26_weeks
+  :mother_salary:
+  - :mother_earned_more_than_lower_earnings_limit
+  :mother_started_working_before_continuity_start_date:
+  - :mother_still_working_on_continuity_end_date
+  :mother_still_working_on_continuity_end_date:
+  - :mother_salary
+  :mother_worked_at_least_26_weeks:
+  - :mother_earned_at_least_390
+  :partner_earned_at_least_390:
+  - :outcome_mat_allowance_mat_leave
+  - :outcome_mat_allowance_mat_leave_mat_shared_leave
+  - :outcome_mat_allowance_mat_leave_pat_leave_both_shared_leave
+  - :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
+  - :outcome_mat_leave
+  - :outcome_mat_leave_mat_pay
+  - :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
+  - :outcome_mat_leave_mat_pay_pat_leave_both_shared_leave_mat_shared_pay
+  - :outcome_mat_leave_mat_pay_pat_leave_pat_shared_leave
+  - :outcome_mat_leave_mat_shared_leave
+  - :outcome_mat_leave_pat_leave
+  - :outcome_mat_leave_pat_leave_mat_shared_leave
+  - :outcome_mat_pay
+  - :outcome_mat_pay_mat_shared_pay
+  - :outcome_mat_pay_pat_leave
+  - :outcome_mat_pay_pat_leave_pat_shared_leave_mat_shared_pay
+  :partner_earned_more_than_lower_earnings_limit:
+  - :outcome_birth_nothing
+  - :outcome_mat_allowance
+  - :outcome_mat_allowance_mat_leave
+  - :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
+  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_both_shared_leave_pat_shared_pay
+  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+  - :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
+  - :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
+  - :outcome_mat_allowance_mat_leave_pat_pay_mat_shared_leave_pat_shared_pay
+  - :outcome_mat_allowance_mat_leave_pat_pay_pat_shared_pay
+  - :outcome_mat_allowance_pat_leave_additional_pat_leave
+  - :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+  - :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+  - :outcome_mat_allowance_pat_leave_pat_shared_leave
+  - :outcome_mat_allowance_pat_pay_additional_pat_pay
+  - :outcome_mat_allowance_pat_pay_pat_shared_pay
+  - :outcome_mat_leave
+  - :outcome_mat_leave_mat_pay
+  - :outcome_mat_leave_mat_pay_pat_leave_additional_pat_leave
+  - :outcome_mat_leave_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+  - :outcome_mat_leave_mat_pay_pat_leave_pat_pay_both_shared_leave_both_shared_pay
+  - :outcome_mat_leave_mat_pay_pat_pay_additional_pat_pay
+  - :outcome_mat_leave_mat_pay_pat_pay_mat_shared_leave_both_shared_pay
+  - :outcome_mat_leave_pat_leave
+  - :outcome_mat_leave_pat_leave_additional_pat_leave
+  - :outcome_mat_leave_pat_leave_pat_pay
+  - :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
+  - :outcome_mat_leave_pat_leave_pat_pay_mat_shared_leave
+  - :outcome_mat_leave_pat_pay
+  - :outcome_mat_leave_pat_pay_mat_shared_leave
+  - :outcome_mat_pay
+  - :outcome_mat_pay_pat_leave_additional_pat_leave
+  - :outcome_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+  - :outcome_mat_pay_pat_leave_pat_pay_pat_shared_leave_both_shared_pay
+  - :outcome_mat_pay_pat_pay_additional_pat_pay
+  - :outcome_mat_pay_pat_pay_both_shared_pay
+  - :outcome_pat_leave
+  - :outcome_pat_leave_pat_pay
+  - :outcome_pat_pay
+  - :partner_worked_at_least_26_weeks
+  :partner_salary:
+  - :partner_earned_more_than_lower_earnings_limit
+  :partner_started_working_before_continuity_start_date:
+  - :partner_still_working_on_continuity_end_date
+  :partner_still_working_on_continuity_end_date:
+  - :partner_salary
+  :partner_worked_at_least_26_weeks:
+  - :partner_earned_at_least_390
+  :salary_1_66_weeks:
+  - :outcome_mat_allowance
+  - :outcome_mat_allowance_mat_leave
+  - :partner_started_working_before_continuity_start_date
+  - :partner_worked_at_least_26_weeks
+  :two_carers:
+  - :due_date
+pip-checker:
+  :are_you_getting_dla?:
+  - :what_is_your_dob?
+  :what_is_your_dob?:
+  - :result_1
+  - :result_2
+  - :result_3
+  - :result_5
+  - :result_6
+  - :result_7
+plan-adoption-leave:
+  :child_arrival_date?:
+  - :leave_start?
+  :child_match_date?:
+  - :child_arrival_date?
+  :leave_start?:
+  - :adoption_leave_details
+register-a-birth:
+  :childs_date_of_birth?:
+  - :homeoffice_result
+  - :where_are_you_now?
+  :country_of_birth?:
+  - :commonwealth_result
+  - :no_embassy_result
+  - :who_has_british_nationality?
+  :married_couple_or_civil_partnership?:
+  - :childs_date_of_birth?
+  - :where_are_you_now?
+  :where_are_you_now?:
+  - :no_birth_certificate_result
+  - :north_korea_result
+  - :oru_result
+  - :which_country?
+  :which_country?:
+  - :north_korea_result
+  - :oru_result
+  :who_has_british_nationality?:
+  - :married_couple_or_civil_partnership?
+  - :no_registration_result
+register-a-death:
+  :did_the_person_die_at_home_hospital?:
+  - :was_death_expected?
+  :was_death_expected?:
+  - :uk_result
+  :where_are_you_now?:
+  - :north_korea_result
+  - :oru_result
+  - :which_country_are_you_in_now?
+  :where_did_the_death_happen?:
+  - :did_the_person_die_at_home_hospital?
+  - :which_country?
+  :which_country?:
+  - :commonwealth_result
+  - :no_embassy_result
+  - :where_are_you_now?
+  :which_country_are_you_in_now?:
+  - :north_korea_result
+  - :oru_result
+report-a-lost-or-stolen-passport:
+  :where_was_the_passport_lost_or_stolen?:
+  - :complete_LS01_form
+  - :which_country?
+  :which_country?:
+  - :contact_the_embassy
+  - :contact_the_embassy_canada
+simplified-expenses-checker:
+  :buying_new_vehicle?:
+  - :capital_allowances?
+  - :how_much_expect_to_claim?
+  - :is_vehicle_green?
+  :capital_allowances?:
+  - :capital_allowance_result
+  - :deduct_from_premises?
+  - :hours_work_home?
+  - :how_much_expect_to_claim?
+  :claimed_expenses_for_current_business?:
+  - :type_of_expense?
+  :current_claim_amount_home?:
+  - :deduct_from_premises?
+  - :you_can_use_result
+  :deduct_from_premises?:
+  - :people_live_on_premises?
+  :drive_business_miles_car_van?:
+  - :deduct_from_premises?
+  - :drive_business_miles_motorcycle?
+  - :hours_work_home?
+  - :you_can_use_result
+  :drive_business_miles_motorcycle?:
+  - :deduct_from_premises?
+  - :hours_work_home?
+  - :you_can_use_result
+  :hours_work_home?:
+  - :current_claim_amount_home?
+  - :you_cant_use_result
+  :how_much_expect_to_claim?:
+  - :drive_business_miles_car_van?
+  - :drive_business_miles_motorcycle?
+  :is_vehicle_green?:
+  - :price_of_vehicle?
+  :people_live_on_premises?:
+  - :you_can_use_result
+  :price_of_vehicle?:
+  - :vehicle_business_use_time?
+  :type_of_expense?:
+  - :buying_new_vehicle?
+  - :deduct_from_premises?
+  - :hours_work_home?
+  - :you_cant_use_result
+  :vehicle_business_use_time?:
+  - :drive_business_miles_car_van?
+  - :drive_business_miles_motorcycle?
+state-pension-age:
+  :dob_age?:
+  - :bus_pass_result
+  - :gender?
+  :gender?:
+  - :has_reached_sp_age
+  - :not_yet_reached_sp_age
+  :which_calculation?:
+  - :dob_age?
+state-pension-through-partner:
+  :what_is_your_gender?:
+  - :age_dependent_pension_outcome
+  - :impossibility_due_to_divorce_outcome
+  - :impossibility_to_increase_pension_outcome
+  - :married_woman_and_state_pension_outcome
+  - :married_woman_no_state_pension_outcome
+  :what_is_your_marital_status?:
+  - :what_is_your_gender?
+  - :when_will_you_reach_pension_age?
+  :when_will_you_reach_pension_age?:
+  - :what_is_your_gender?
+  - :when_will_your_partner_reach_pension_age?
+  - :widow_and_old_pension_outcome
+  :when_will_your_partner_reach_pension_age?:
+  - :current_rules_national_insurance_no_state_pension_outcome
+  - :current_rules_no_additional_pension_outcome
+  - :what_is_your_gender?
+state-pension-topup:
+  :dob_age?:
+  - :gender?
+  - :outcome_pension_age_not_reached
+  :gender?:
+  - :how_much_extra_per_week?
+  - :outcome_pension_age_not_reached
+  :how_much_extra_per_week?:
+  - :outcome_topup_calculations
+student-finance-calculator:
+  :do_any_of_the_following_apply_all_uk_students?:
+  - :what_course_are_you_studying?
+  :do_any_of_the_following_apply_uk_full_time_students_only?:
+  - :what_course_are_you_studying?
+  :how_much_are_your_tuition_fees_per_year?:
+  - :do_any_of_the_following_apply_all_uk_students?
+  - :outcome_eu_students
+  - :where_will_you_live_while_studying?
+  :what_course_are_you_studying?:
+  - :outcome_eu_students
+  - :outcome_uk_all_students
+  - :outcome_uk_full_time_students
+  :what_type_of_student_are_you?:
+  - :how_much_are_your_tuition_fees_per_year?
+  :whats_your_household_income?:
+  - :do_any_of_the_following_apply_uk_full_time_students_only?
+  :when_does_your_course_start?:
+  - :what_type_of_student_are_you?
+  :where_will_you_live_while_studying?:
+  - :whats_your_household_income?
+student-finance-forms:
+  :continuing_student?:
+  - :outcome_eu_ft_1516_continuing
+  - :outcome_eu_ft_1516_new
+  - :outcome_eu_ft_1617_continuing
+  - :outcome_eu_ft_1617_new
+  - :outcome_eu_pt_1415_continuing
+  - :outcome_eu_pt_1415_new
+  - :outcome_eu_pt_1516_continuing
+  - :outcome_eu_pt_1516_new
+  - :outcome_uk_ft_1516_continuing
+  - :outcome_uk_ft_1516_new
+  - :outcome_uk_ft_1617_continuing
+  - :outcome_uk_ft_1617_new
+  - :pt_course_start?
+  :form_needed_for_1?:
+  - :outcome_ccg_expenses
+  - :outcome_dsa_expenses
+  - :outcome_travel
+  - :what_year_full_time?
+  :form_needed_for_2?:
+  - :outcome_dsa_expenses
+  - :what_year_part_time?
+  :pt_course_start?:
+  - :outcome_uk_pt_1415_continuing
+  - :outcome_uk_pt_1415_grant
+  - :outcome_uk_pt_1415_new
+  - :outcome_uk_pt_1516_continuing
+  - :outcome_uk_pt_1516_new
+  - :outcome_uk_ptgc_1516_grant
+  - :outcome_uk_ptgn_1516_grant
+  :type_of_student?:
+  - :form_needed_for_1?
+  - :form_needed_for_2?
+  - :what_year_full_time?
+  - :what_year_part_time?
+  :what_year_full_time?:
+  - :continuing_student?
+  - :outcome_ccg_1516
+  - :outcome_ccg_1617
+  - :outcome_dsa_1516
+  - :outcome_dsa_1617
+  - :outcome_parent_partner_1516
+  - :outcome_parent_partner_1617
+  - :outcome_proof_identity_1516
+  - :outcome_proof_identity_1617
+  :what_year_part_time?:
+  - :continuing_student?
+  - :outcome_dsa_1415_pt
+  - :outcome_dsa_1516_pt
+  - :outcome_proof_identity_1415
+  - :outcome_proof_identity_1516
+towing-rules:
+  :bus_licenceholder?:
+  - :full_entitlement_bus
+  - :how_old_are_you_bus?
+  :car_licence_before_jan_1997?:
+  - :do_you_have_lv_or_bus_towing_entitlement?
+  - :full_entitlement_minibus
+  :date_licence_was_issued?:
+  - :limited_trailer_entitlement
+  - :limited_trailer_entitlement_2013
+  :date_licence_was_issued_msv?:
+  - :full_entitlement_msv
+  - :how_old_are_you_msv_2?
+  :do_you_have_lv_or_bus_towing_entitlement?:
+  - :full_minibus_licence?
+  - :included_entitlement_minibus
+  :existing_large_vehicle_licence?:
+  - :full_cat_c_entitlement
+  - :how_old_are_you_lv?
+  :existing_large_vehicle_towing_entitlements?:
+  - :date_licence_was_issued_msv?
+  - :included_entitlement_msv
+  :existing_towing_entitlements?:
+  - :date_licence_was_issued?
+  - :how_long_entitlements?
+  :full_minibus_licence?:
+  - :how_old_are_you_minibus?
+  - :limited_towing_entitlement_minibus
+  :how_long_entitlements?:
+  - :car_light_vehicle_entitlement
+  - :full_entitlement
+  :how_old_are_you_bus?:
+  - :apply_for_provisional_bus
+  - :not_old_enough_bus
+  :how_old_are_you_lv?:
+  - :apply_for_provisional_lv
+  - :not_old_enough_lv
+  :how_old_are_you_minibus?:
+  - :limited_overall_entitlement_minibus
+  - :not_old_enough_minibus
+  :how_old_are_you_msv?:
+  - :limited_conditional_trailer_entitlement_msv
+  - :limited_trailer_entitlement_msv
+  :how_old_are_you_msv_2?:
+  - :apply_for_provisional_msv
+  - :apply_for_provisional_with_exceptions_msv
+  - :too_young_msv
+  :medium_sized_vehicle_licenceholder?:
+  - :existing_large_vehicle_towing_entitlements?
+  - :how_old_are_you_msv?
+  :towing_vehicle_type?:
+  - :bus_licenceholder?
+  - :car_licence_before_jan_1997?
+  - :existing_large_vehicle_licence?
+  - :existing_towing_entitlements?
+  - :medium_sized_vehicle_licenceholder?
+uk-benefits-abroad:
+  :db_claiming_benefits?:
+  - :db_already_abroad_eea_outcome
+  - :db_already_abroad_other_outcome
+  - :db_going_abroad_eea_outcome
+  - :db_going_abroad_other_outcome
+  :db_how_long_abroad?:
+  - :db_already_abroad_temporary_outcome
+  - :db_going_abroad_temporary_outcome
+  - :which_country?
+  :do_either_of_the_following_apply?:
+  - :child_benefit_entitled_outcome
+  - :child_benefit_not_entitled_outcome
+  :eligible_for_smp?:
+  - :maternity_benefits_eea_entitled_outcome
+  - :maternity_benefits_maternity_allowance_outcome
+  :eligible_for_tax_credits?:
+  - :tax_credits_cross_border_worker_outcome
+  - :tax_credits_crown_servant_outcome
+  - :tax_credits_how_long_abroad?
+  :employer_paying_ni?:
+  - :eligible_for_smp?
+  - :maternity_benefits_not_entitled_outcome
+  - :maternity_benefits_social_security_already_abroad_outcome
+  - :maternity_benefits_social_security_going_abroad_outcome
+  - :ssp_already_abroad_entitled_outcome
+  - :ssp_already_abroad_not_entitled_outcome
+  - :ssp_going_abroad_entitled_outcome
+  - :ssp_going_abroad_not_entitled_outcome
+  :esa_how_long_abroad?:
+  - :esa_already_abroad_under_a_year_medical_outcome
+  - :esa_already_abroad_under_a_year_other_outcome
+  - :esa_going_abroad_under_a_year_medical_outcome
+  - :esa_going_abroad_under_a_year_other_outcome
+  - :which_country?
+  :going_or_already_abroad?:
+  - :which_benefit?
+  :iidb_already_claiming?:
+  - :iidb_maybe_outcome
+  - :which_country?
+  :is_abroad_for_treatment?:
+  - :is_abroad_for_treatment_outcome
+  - :is_work_or_sick_pay?
+  :is_any_of_the_following_apply?:
+  - :is_abroad_for_treatment_outcome
+  - :is_not_eligible_outcome
+  :is_claiming_benefits?:
+  - :is_claiming_benefits_outcome
+  - :is_either_of_the_following?
+  :is_either_of_the_following?:
+  - :is_abroad_for_treatment?
+  - :is_any_of_the_following_apply?
+  :is_how_long_abroad?:
+  - :is_claiming_benefits?
+  - :is_more_than_a_year_outcome
+  - :is_under_a_year_medical_outcome
+  :is_work_or_sick_pay?:
+  - :is_abroad_for_treatment_outcome
+  - :is_not_eligible_outcome
+  :jsa_how_long_abroad?:
+  - :jsa_less_than_a_year_medical_outcome
+  - :jsa_less_than_a_year_other_outcome
+  - :which_country?
+  :tax_credits_children?:
+  - :tax_credits_unlikely_outcome
+  - :which_country?
+  :tax_credits_currently_claiming?:
+  - :tax_credits_eea_entitled_outcome
+  - :tax_credits_unlikely_outcome
+  :tax_credits_how_long_abroad?:
+  - :tax_credits_children?
+  - :tax_credits_why_going_abroad?
+  :tax_credits_why_going_abroad?:
+  - :tax_credits_holiday_outcome
+  - :tax_credits_medical_death_outcome
+  :which_benefit?:
+  - :db_how_long_abroad?
+  - :eligible_for_tax_credits?
+  - :esa_how_long_abroad?
+  - :iidb_already_claiming?
+  - :is_already_abroad_outcome
+  - :is_how_long_abroad?
+  - :jsa_how_long_abroad?
+  - :pension_already_abroad_outcome
+  - :pension_going_abroad_outcome
+  - :which_country?
+  :which_country?:
+  - :bb_already_abroad_eea_outcome
+  - :bb_already_abroad_other_outcome
+  - :bb_already_abroad_ss_outcome
+  - :bb_going_abroad_eea_outcome
+  - :bb_going_abroad_other_outcome
+  - :bb_going_abroad_ss_outcome
+  - :child_benefit_fy_already_abroad_outcome
+  - :child_benefit_fy_going_abroad_outcome
+  - :child_benefit_jtu_outcome
+  - :child_benefit_not_entitled_outcome
+  - :child_benefit_ss_outcome
+  - :db_already_abroad_other_outcome
+  - :db_claiming_benefits?
+  - :db_going_abroad_other_outcome
+  - :do_either_of_the_following_apply?
+  - :employer_paying_ni?
+  - :esa_already_abroad_eea_outcome
+  - :esa_already_abroad_other_outcome
+  - :esa_already_abroad_ss_outcome
+  - :esa_going_abroad_eea_outcome
+  - :esa_going_abroad_other_outcome
+  - :iidb_already_abroad_eea_outcome
+  - :iidb_already_abroad_other_outcome
+  - :iidb_already_abroad_ss_outcome
+  - :iidb_going_abroad_eea_outcome
+  - :iidb_going_abroad_other_outcome
+  - :iidb_going_abroad_ss_outcome
+  - :jsa_eea_already_abroad_outcome
+  - :jsa_eea_going_abroad_outcome
+  - :jsa_not_entitled_outcome
+  - :jsa_social_security_already_abroad_outcome
+  - :jsa_social_security_going_abroad_outcome
+  - :tax_credits_currently_claiming?
+  - :tax_credits_unlikely_outcome
+  - :wfp_eea_eligible_outcome
+  - :wfp_going_abroad_outcome
+  - :wfp_not_eligible_outcome
+  - :working_for_a_uk_employer?
+  - :working_for_uk_employer_ssp?
+  :working_for_a_uk_employer?:
+  - :eligible_for_smp?
+  - :maternity_benefits_maternity_allowance_outcome
+  :working_for_uk_employer_ssp?:
+  - :ssp_already_abroad_entitled_outcome
+  - :ssp_already_abroad_not_entitled_outcome
+  - :ssp_going_abroad_entitled_outcome
+  - :ssp_going_abroad_not_entitled_outcome
+vat-payment-deadlines:
+  :how_do_you_want_to_pay?:
+  - :result_bacs_direct_credit
+  - :result_bank_giro
+  - :result_chaps
+  - :result_cheque
+  - :result_direct_debit
+  - :result_online_debit_credit_card
+  - :result_online_telephone_banking
+  :when_does_your_vat_accounting_period_end?:
+  - :how_do_you_want_to_pay?

From 1125b61ecbf2cdada0a30e5c5be2d9d8f633cac3 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 16:13:20 +0100
Subject: [PATCH 03/44] Automatic next_node detection in
 additional-commodity-code

---
 .../additional-commodity-code.rb              | 40 ++++++-------------
 test/data/additional-commodity-code-files.yml |  2 +-
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/lib/smart_answer_flows/additional-commodity-code.rb b/lib/smart_answer_flows/additional-commodity-code.rb
index 9ee7df77708..234c0108c6b 100644
--- a/lib/smart_answer_flows/additional-commodity-code.rb
+++ b/lib/smart_answer_flows/additional-commodity-code.rb
@@ -21,23 +21,16 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :how_much_sucrose_1?,
-          :how_much_sucrose_2?,
-          :how_much_sucrose_3?,
-          :how_much_sucrose_4?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response.to_i
           when 25
-            :how_much_sucrose_2?
+            question :how_much_sucrose_2?
           when 50
-            :how_much_sucrose_3?
+            question :how_much_sucrose_3?
           when 75
-            :how_much_sucrose_4?
+            question :how_much_sucrose_4?
           else
-            :how_much_sucrose_1?
+            question :how_much_sucrose_1?
           end
         end
       end
@@ -101,29 +94,20 @@ def define
 
         save_input_as :milk_fat_weight
 
-        permitted_next_nodes = [
-          :commodity_code_result,
-          :how_much_milk_protein_ab?,
-          :how_much_milk_protein_c?,
-          :how_much_milk_protein_d?,
-          :how_much_milk_protein_ef?,
-          :how_much_milk_protein_gh?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response.to_i
           when 0, 1
-            :how_much_milk_protein_ab?
+            question :how_much_milk_protein_ab?
           when 3
-            :how_much_milk_protein_c?
+            question :how_much_milk_protein_c?
           when 6
-            :how_much_milk_protein_d?
+            question :how_much_milk_protein_d?
           when 9, 12
-            :how_much_milk_protein_ef?
+            question :how_much_milk_protein_ef?
           when 18, 26
-            :how_much_milk_protein_gh?
+            question :how_much_milk_protein_gh?
           else
-            :commodity_code_result
+            outcome :commodity_code_result
           end
         end
       end
diff --git a/test/data/additional-commodity-code-files.yml b/test/data/additional-commodity-code-files.yml
index a221023a2e0..407057c45ec 100644
--- a/test/data/additional-commodity-code-files.yml
+++ b/test/data/additional-commodity-code-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/additional-commodity-code.rb: 4b0f5a4e9134dc04651da374c15d851b
+lib/smart_answer_flows/additional-commodity-code.rb: dfe86cba48b402b475a607473f1b7ce4
 test/data/additional-commodity-code-questions-and-responses.yml: 24243e9af7ed9c7aca5ed6adbfa0c9b7
 test/data/additional-commodity-code-responses-and-expected-results.yml: 3f80e1b92ec7731959b0f8033a4f43c8
 lib/smart_answer_flows/additional-commodity-code/additional_commodity_code.govspeak.erb: 4d11f8bf0bcd29764893c4a12349de17

From ffc1c2211f291ec2ad317211c83cc5ced57516ae Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 16:18:56 +0100
Subject: [PATCH 04/44] Automatic next_node detection in
 am-i-getting-minimum-wage

---
 .../am-i-getting-minimum-wage.rb              | 36 ++++++-------------
 test/data/am-i-getting-minimum-wage-files.yml |  2 +-
 2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/lib/smart_answer_flows/am-i-getting-minimum-wage.rb b/lib/smart_answer_flows/am-i-getting-minimum-wage.rb
index 20d5130bf88..637addca7b1 100644
--- a/lib/smart_answer_flows/am-i-getting-minimum-wage.rb
+++ b/lib/smart_answer_flows/am-i-getting-minimum-wage.rb
@@ -20,20 +20,14 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :are_you_an_apprentice?,
-          :will_you_be_a_first_year_apprentice?,
-          :past_payment_date?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'current_payment'
-            :are_you_an_apprentice?
+            question :are_you_an_apprentice?
           when 'current_payment_april_2016'
-            :will_you_be_a_first_year_apprentice?
+            question :will_you_be_a_first_year_apprentice?
           when 'past_payment'
-            :past_payment_date?
+            question :past_payment_date?
           end
         end
       end
@@ -43,18 +37,13 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :does_not_apply_to_first_year_apprentices,
-          :how_old_are_you?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
             calculator.is_apprentice = true
-            :does_not_apply_to_first_year_apprentices
+            outcome :does_not_apply_to_first_year_apprentices
           when 'no'
-            :how_old_are_you? #Q3
+            question :how_old_are_you? #Q3
           end
         end
       end
@@ -81,17 +70,12 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :under_school_leaving_age,
-          :how_often_do_you_get_paid?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.age = response
           if calculator.under_school_leaving_age?
-            :under_school_leaving_age
+            outcome :under_school_leaving_age
           else
-            :how_often_do_you_get_paid?
+            question :how_often_do_you_get_paid?
           end
         end
       end
diff --git a/test/data/am-i-getting-minimum-wage-files.yml b/test/data/am-i-getting-minimum-wage-files.yml
index 1dbe5d147af..72f6eb31b26 100644
--- a/test/data/am-i-getting-minimum-wage-files.yml
+++ b/test/data/am-i-getting-minimum-wage-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/am-i-getting-minimum-wage.rb: b6265a5c47c5696a14cebd7965f833cd
+lib/smart_answer_flows/am-i-getting-minimum-wage.rb: 970b193a69af66df0e7f02e104890dae
 test/data/am-i-getting-minimum-wage-questions-and-responses.yml: 212c0b6343d812ba81b18cb940bfba35
 test/data/am-i-getting-minimum-wage-responses-and-expected-results.yml: ee1cc2d8ee436f03a31203c4dbc3ef70
 lib/smart_answer_flows/am-i-getting-minimum-wage/am_i_getting_minimum_wage.govspeak.erb: e3bad2e005bb806999594e9f87f5e5ae

From d7b26f0c3a219740f1b6e9dc6723936617cdee87 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 16:36:29 +0100
Subject: [PATCH 05/44] Automatic next_node detection in benefit-cap-calculator

I couldn't use `:auto` for all the `next_node` blocks, because some of them have
dynamic results which can't be auto-detected.
---
 .../benefit-cap-calculator.rb                 | 44 +++++--------------
 test/data/benefit-cap-calculator-files.yml    |  2 +-
 2 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/lib/smart_answer_flows/benefit-cap-calculator.rb b/lib/smart_answer_flows/benefit-cap-calculator.rb
index 6a2286cb06e..3072125fea5 100644
--- a/lib/smart_answer_flows/benefit-cap-calculator.rb
+++ b/lib/smart_answer_flows/benefit-cap-calculator.rb
@@ -13,16 +13,11 @@ def define
 
         save_input_as :housing_benefit
 
-        permitted_next_nodes = [
-          :working_tax_credit?,
-          :outcome_not_affected_no_housing_benefit
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'yes'
-            :working_tax_credit?
+            question :working_tax_credit?
           else
-            :outcome_not_affected_no_housing_benefit
+            outcome :outcome_not_affected_no_housing_benefit
           end
         end
       end
@@ -32,16 +27,11 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :outcome_not_affected_exemptions,
-          :receiving_exemption_benefits?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'yes'
-            :outcome_not_affected_exemptions
+            outcome :outcome_not_affected_exemptions
           else
-            :receiving_exemption_benefits?
+            question :receiving_exemption_benefits?
           end
         end
       end
@@ -51,16 +41,11 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :outcome_not_affected_exemptions,
-          :receiving_non_exemption_benefits?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'yes'
-            :outcome_not_affected_exemptions
+            outcome :outcome_not_affected_exemptions
           else
-            :receiving_non_exemption_benefits?
+            question :receiving_non_exemption_benefits?
           end
         end
       end
@@ -521,12 +506,7 @@ def define
           sprintf("%.2f", benefit_cap)
         end
 
-        permitted_next_nodes = [
-          :outcome_affected_greater_than_cap,
-          :outcome_not_affected_less_than_cap
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'single'
             cap = 350
           else
@@ -534,9 +514,9 @@ def define
           end
 
           if total_benefits > cap
-            :outcome_affected_greater_than_cap
+            outcome :outcome_affected_greater_than_cap
           else
-            :outcome_not_affected_less_than_cap
+            outcome :outcome_not_affected_less_than_cap
           end
         end
       end
diff --git a/test/data/benefit-cap-calculator-files.yml b/test/data/benefit-cap-calculator-files.yml
index 08f2ed1334f..3dbe0d97684 100644
--- a/test/data/benefit-cap-calculator-files.yml
+++ b/test/data/benefit-cap-calculator-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/benefit-cap-calculator.rb: 3272eb6344567f88ec75694fc1d4b7d6
+lib/smart_answer_flows/benefit-cap-calculator.rb: 8d0a35d30925354045bad4d463c49da9
 test/data/benefit-cap-calculator-questions-and-responses.yml: b608788e9eb18ad20a066de99259aa84
 test/data/benefit-cap-calculator-responses-and-expected-results.yml: 497ab9a2846c8821e61ac28c5b0d6cc1
 lib/smart_answer_flows/benefit-cap-calculator/benefit_cap_calculator.govspeak.erb: ce5203f11989c0b35bd9c53ade1f3f82

From 37747eb0eaf138481fe4ad619983c469b0132e15 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 16:40:16 +0100
Subject: [PATCH 06/44] Automatic next_node detection in
 calculate-agricultural-holiday-entitlement

---
 ...culate-agricultural-holiday-entitlement.rb | 20 ++++++-------------
 ...agricultural-holiday-entitlement-files.yml |  2 +-
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb b/lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb
index 46a55898cb6..7877e98585a 100644
--- a/lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb
+++ b/lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb
@@ -16,16 +16,12 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :how_many_days_per_week?,
-          :what_date_does_holiday_start?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'same-number-of-days'
-            :how_many_days_per_week?
+            question :how_many_days_per_week?
           when 'different-number-of-days'
-            :what_date_does_holiday_start?
+            question :what_date_does_holiday_start?
           end
         end
       end
@@ -77,16 +73,12 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :done,
-          :how_many_weeks_at_current_employer?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'same-employer'
-            :done
+            outcome :done
           when 'multiple-employers'
-            :how_many_weeks_at_current_employer?
+            question :how_many_weeks_at_current_employer?
           end
         end
       end
diff --git a/test/data/calculate-agricultural-holiday-entitlement-files.yml b/test/data/calculate-agricultural-holiday-entitlement-files.yml
index a269b7a5010..b59cca038a2 100644
--- a/test/data/calculate-agricultural-holiday-entitlement-files.yml
+++ b/test/data/calculate-agricultural-holiday-entitlement-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb: 86995ba75ad783a09dc0c62143916faf
+lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb: 3c6637ca9b74b89f353a824b3d931a03
 test/data/calculate-agricultural-holiday-entitlement-questions-and-responses.yml: 4b91e0ca75c21fa5d93abc1944bfa8d4
 test/data/calculate-agricultural-holiday-entitlement-responses-and-expected-results.yml: bbf1e135027230dbab56e67c87206edd
 lib/smart_answer_flows/calculate-agricultural-holiday-entitlement/calculate_agricultural_holiday_entitlement.govspeak.erb: 37d391a5a3a5d8d8feb760f79048af4e

From 988036ec05799e1d850b34de4fd9b6dc4c983d0e Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 16:44:25 +0100
Subject: [PATCH 07/44] Automatic next_node detection in
 calculate-married-couples-allowance

---
 .../calculate-married-couples-allowance.rb    | 60 ++++++-------------
 ...culate-married-couples-allowance-files.yml |  2 +-
 2 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/lib/smart_answer_flows/calculate-married-couples-allowance.rb b/lib/smart_answer_flows/calculate-married-couples-allowance.rb
index 63f120e1ac1..a0eea9a09c3 100644
--- a/lib/smart_answer_flows/calculate-married-couples-allowance.rb
+++ b/lib/smart_answer_flows/calculate-married-couples-allowance.rb
@@ -33,16 +33,12 @@ def define
           Calculators::MarriedCouplesAllowanceCalculator.new(validate_income: false)
         end
 
-        permitted_next_nodes = [
-          :did_you_marry_or_civil_partner_before_5_december_2005?,
-          :sorry
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :did_you_marry_or_civil_partner_before_5_december_2005?
+            question :did_you_marry_or_civil_partner_before_5_december_2005?
           when 'no'
-            :sorry
+            outcome :sorry
           end
         end
       end
@@ -62,16 +58,12 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :whats_the_husbands_date_of_birth?,
-          :whats_the_highest_earners_date_of_birth?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :whats_the_husbands_date_of_birth?
+            question :whats_the_husbands_date_of_birth?
           when 'no'
-            :whats_the_highest_earners_date_of_birth?
+            question :whats_the_highest_earners_date_of_birth?
           end
         end
       end
@@ -97,16 +89,12 @@ def define
 
         validate { |response| response > 0 }
 
-        permitted_next_nodes = [
-          :paying_into_a_pension?,
-          :husband_done
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           limit = (is_before_april_changes ? 26100.0 : 27000.0)
           if response.to_f >= limit
-            :paying_into_a_pension?
+            question :paying_into_a_pension?
           else
-            :husband_done
+            outcome :husband_done
           end
         end
       end
@@ -116,16 +104,12 @@ def define
 
         validate { |response| response > 0 }
 
-        permitted_next_nodes = [
-          :paying_into_a_pension?,
-          :highest_earner_done
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           limit = (is_before_april_changes ? 26100.0 : 27000.0)
           if response.to_f >= limit
-            :paying_into_a_pension?
+            question :paying_into_a_pension?
           else
-            :highest_earner_done
+            outcome :highest_earner_done
           end
         end
       end
@@ -134,16 +118,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :how_much_expected_contributions_before_tax?,
-          :how_much_expected_gift_aided_donations?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_much_expected_contributions_before_tax?
+            question :how_much_expected_contributions_before_tax?
           when 'no'
-            :how_much_expected_gift_aided_donations?
+            question :how_much_expected_gift_aided_donations?
           end
         end
       end
@@ -165,15 +145,11 @@ def define
           calculator.calculate_adjusted_net_income(income.to_f, (gross_pension_contributions.to_f || 0), (net_pension_contributions.to_f || 0), response)
         end
 
-        permitted_next_nodes = [
-          :husband_done,
-          :highest_earner_done
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if income_measure == "husband"
-            :husband_done
+            outcome :husband_done
           else
-            :highest_earner_done
+            outcome :highest_earner_done
           end
         end
       end
diff --git a/test/data/calculate-married-couples-allowance-files.yml b/test/data/calculate-married-couples-allowance-files.yml
index 70e02f20eff..e8144a56f81 100644
--- a/test/data/calculate-married-couples-allowance-files.yml
+++ b/test/data/calculate-married-couples-allowance-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/calculate-married-couples-allowance.rb: d36fd014e01678f20d770c7d57975c8e
+lib/smart_answer_flows/calculate-married-couples-allowance.rb: b3e667634fb12a99866249450e07535e
 test/data/calculate-married-couples-allowance-questions-and-responses.yml: 3cdcbf373de49fa6383b7dcb1967eb80
 test/data/calculate-married-couples-allowance-responses-and-expected-results.yml: 3a6d219be3fceda5e5e091520ab5227f
 lib/smart_answer_flows/calculate-married-couples-allowance/calculate_married_couples_allowance.govspeak.erb: 2a107c5f5eccf492a1bbb055fb87ee2c

From b3c3992f5cc929cc6710ff8084fd0150035e3f1a Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 17:05:47 +0100
Subject: [PATCH 08/44] Automatic next_node detection in
 calculate-statutory-sick-pay

---
 .../calculate-statutory-sick-pay.rb           | 118 +++++++-----------
 .../calculate-statutory-sick-pay-files.yml    |   2 +-
 2 files changed, 48 insertions(+), 72 deletions(-)

diff --git a/lib/smart_answer_flows/calculate-statutory-sick-pay.rb b/lib/smart_answer_flows/calculate-statutory-sick-pay.rb
index d1a7c4a3186..9ae6ccd66b2 100644
--- a/lib/smart_answer_flows/calculate-statutory-sick-pay.rb
+++ b/lib/smart_answer_flows/calculate-statutory-sick-pay.rb
@@ -19,13 +19,12 @@ def define
           Calculators::StatutorySickPayCalculator.new
         end
 
-        permitted_next_nodes = [:employee_tell_within_limit?, :already_getting_maternity]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.other_pay_types_received = response.split(",")
           if calculator.already_getting_maternity_pay?
-            :already_getting_maternity
+            outcome :already_getting_maternity
           else
-            :employee_tell_within_limit?
+            question :employee_tell_within_limit?
           end
         end
       end
@@ -35,13 +34,13 @@ def define
         option :yes
         option :no
 
-        next_node(permitted: [:employee_work_different_days?]) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'yes'
             calculator.enough_notice_of_absence = true
           else
             calculator.enough_notice_of_absence = false
           end
-          :employee_work_different_days?
+          question :employee_work_different_days?
         end
       end
 
@@ -50,16 +49,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :not_regular_schedule,
-          :first_sick_day?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :not_regular_schedule # Answer 4
+            outcome :not_regular_schedule # Answer 4
           when 'no'
-            :first_sick_day? # Question 4
+            question :first_sick_day? # Question 4
           end
         end
       end
@@ -70,9 +65,9 @@ def define
         to { Date.today.end_of_year }
         validate_in_range
 
-        next_node(permitted: [:last_sick_day?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.sick_start_date = response
-          :last_sick_day?
+          question :last_sick_day?
         end
       end
 
@@ -86,13 +81,12 @@ def define
           calculator.valid_last_sick_day?(response)
         end
 
-        permitted_next_nodes = [:has_linked_sickness?, :must_be_sick_for_4_days]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.sick_end_date = response
           if calculator.valid_period_of_incapacity_for_work?
-            :has_linked_sickness?
+            question :has_linked_sickness?
           else
-            :must_be_sick_for_4_days
+            outcome :must_be_sick_for_4_days
           end
         end
       end
@@ -102,18 +96,14 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :linked_sickness_start_date?,
-          :paid_at_least_8_weeks?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
             calculator.has_linked_sickness = true
-            :linked_sickness_start_date?
+            question :linked_sickness_start_date?
           when 'no'
             calculator.has_linked_sickness = false
-            :paid_at_least_8_weeks?
+            question :paid_at_least_8_weeks?
           end
         end
       end
@@ -128,9 +118,9 @@ def define
           calculator.valid_linked_sickness_start_date?(response)
         end
 
-        next_node(permitted: [:linked_sickness_end_date?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.linked_sickness_start_date = response
-          :linked_sickness_end_date?
+          question :linked_sickness_end_date?
         end
       end
 
@@ -152,9 +142,9 @@ def define
           calculator.valid_linked_period_of_incapacity_for_work?(response)
         end
 
-        next_node(permitted: [:paid_at_least_8_weeks?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.linked_sickness_end_date = response
-          :paid_at_least_8_weeks?
+          question :paid_at_least_8_weeks?
         end
       end
 
@@ -168,18 +158,14 @@ def define
           calculator.sick_start_date_for_awe
         end
 
-        permitted_next_nodes = [
-          :how_often_pay_employee_pay_patterns?,
-          :total_earnings_before_sick_period?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.eight_weeks_earnings = response
           if calculator.paid_at_least_8_weeks_of_earnings?
-            :how_often_pay_employee_pay_patterns? # Question 7.2
+            question :how_often_pay_employee_pay_patterns? # Question 7.2
           elsif calculator.paid_less_than_8_weeks_of_earnings?
-            :total_earnings_before_sick_period? # Question 10
+            question :total_earnings_before_sick_period? # Question 10
           elsif calculator.fell_sick_before_payday?
-            :how_often_pay_employee_pay_patterns? # Question 7.2
+            question :how_often_pay_employee_pay_patterns? # Question 7.2
           end
         end
       end
@@ -192,16 +178,12 @@ def define
         option :monthly
         option :irregularly
 
-        permitted_next_nodes = [
-          :last_payday_before_sickness?,
-          :pay_amount_if_not_sick?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.pay_pattern = response
           if calculator.paid_at_least_8_weeks_of_earnings?
-            :last_payday_before_sickness? # Question 8
+            question :last_payday_before_sickness? # Question 8
           else
-            :pay_amount_if_not_sick? # Question 9
+            question :pay_amount_if_not_sick? # Question 9
           end
         end
       end
@@ -220,9 +202,9 @@ def define
           calculator.valid_last_payday_before_sickness?(response)
         end
 
-        next_node(permitted: [:last_payday_before_offset?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.relevant_period_to = response
-          :last_payday_before_offset?
+          question :last_payday_before_offset?
         end
       end
 
@@ -240,9 +222,9 @@ def define
           calculator.valid_last_payday_before_offset?(response)
         end
 
-        next_node(permitted: [:total_employee_earnings?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.relevant_period_from = response + 1.day
-          :total_employee_earnings?
+          question :total_employee_earnings?
         end
       end
 
@@ -256,9 +238,9 @@ def define
           calculator.relevant_period_to
         end
 
-        next_node(permitted: [:usual_work_days?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.total_employee_earnings = response
-          :usual_work_days?
+          question :usual_work_days?
         end
       end
 
@@ -268,33 +250,33 @@ def define
           calculator.sick_start_date_for_awe
         end
 
-        next_node(permitted: [:contractual_days_covered_by_earnings?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.relevant_contractual_pay = response
-          :contractual_days_covered_by_earnings?
+          question :contractual_days_covered_by_earnings?
         end
       end
 
       # Question 9.1
       value_question :contractual_days_covered_by_earnings? do
-        next_node(permitted: [:usual_work_days?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.contractual_days_covered_by_earnings = response
-          :usual_work_days?
+          question :usual_work_days?
         end
       end
 
       # Question 10
       money_question :total_earnings_before_sick_period? do
-        next_node(permitted: [:days_covered_by_earnings?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.total_earnings_before_sick_period = response
-          :days_covered_by_earnings?
+          question :days_covered_by_earnings?
         end
       end
 
       # Question 10.1
       value_question :days_covered_by_earnings? do
-        next_node(permitted: [:usual_work_days?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.days_covered_by_earnings = response.to_i
-          :usual_work_days?
+          question :usual_work_days?
         end
       end
 
@@ -302,24 +284,18 @@ def define
       checkbox_question :usual_work_days? do
         %w{1 2 3 4 5 6 0}.each { |n| option n.to_s }
 
-        permitted_next_nodes = [
-          :not_earned_enough,
-          :maximum_entitlement_reached,
-          :entitled_to_sick_pay,
-          :not_entitled_3_days_not_paid
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.days_of_the_week_worked = response.split(",")
           if calculator.not_earned_enough?
-            :not_earned_enough
+            outcome :not_earned_enough
           elsif calculator.maximum_entitlement_reached?
-            :maximum_entitlement_reached # Answer 8
+            outcome :maximum_entitlement_reached # Answer 8
           elsif calculator.entitled_to_sick_pay?
-            :entitled_to_sick_pay # Answer 6
+            outcome :entitled_to_sick_pay # Answer 6
           elsif calculator.maximum_entitlement_reached_v2?
-            :maximum_entitlement_reached # Answer 8
+            outcome :maximum_entitlement_reached # Answer 8
           else
-            :not_entitled_3_days_not_paid # Answer 7
+            outcome :not_entitled_3_days_not_paid # Answer 7
           end
         end
       end
diff --git a/test/data/calculate-statutory-sick-pay-files.yml b/test/data/calculate-statutory-sick-pay-files.yml
index 38b2aa8ee9e..f67ed879f81 100644
--- a/test/data/calculate-statutory-sick-pay-files.yml
+++ b/test/data/calculate-statutory-sick-pay-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/calculate-statutory-sick-pay.rb: e6ecafcf953264457fa795c583b08c27
+lib/smart_answer_flows/calculate-statutory-sick-pay.rb: 1239774f9ff9fba41e93a373751d2159
 test/data/calculate-statutory-sick-pay-questions-and-responses.yml: dfd8baf65a8c26430cf17958e8908202
 test/data/calculate-statutory-sick-pay-responses-and-expected-results.yml: b42519fbb030e7eaf0912d1de0b8ff47
 lib/smart_answer_flows/calculate-statutory-sick-pay/calculate_statutory_sick_pay.govspeak.erb: f91dc1d321c164a06271889100875600

From 42f3a5a5c0265c84a1714bb934f0249172d94404 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 17:19:39 +0100
Subject: [PATCH 09/44] Automatic next_node detection in
 calculate-your-child-maintenance

---
 .../calculate-your-child-maintenance.rb       | 36 ++++++-------------
 ...calculate-your-child-maintenance-files.yml |  2 +-
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/lib/smart_answer_flows/calculate-your-child-maintenance.rb b/lib/smart_answer_flows/calculate-your-child-maintenance.rb
index 2a53b55281e..473c221c0f7 100644
--- a/lib/smart_answer_flows/calculate-your-child-maintenance.rb
+++ b/lib/smart_answer_flows/calculate-your-child-maintenance.rb
@@ -60,16 +60,12 @@ def define
           Calculators::ChildMaintenanceCalculator.new(number_of_children, benefits, paying_or_receiving)
         end
 
-        permitted_next_nodes = [
-          :how_many_nights_children_stay_with_payee?,
-          :gross_income_of_payee?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_many_nights_children_stay_with_payee?
+            question :how_many_nights_children_stay_with_payee?
           when 'no'
-            :gross_income_of_payee?
+            question :gross_income_of_payee?
           end
         end
       end
@@ -90,19 +86,14 @@ def define
           calculator.rate_type
         end
 
-        permitted_next_nodes = [
-          :nil_rate_result,
-          :flat_rate_result,
-          :how_many_other_children_in_payees_household?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case rate_type
           when :nil
-            :nil_rate_result
+            outcome :nil_rate_result
           when :flat
-            :flat_rate_result
+            outcome :flat_rate_result
           else
-            :how_many_other_children_in_payees_household?
+            question :how_many_other_children_in_payees_household?
           end
         end
       end
@@ -151,19 +142,14 @@ def define
           calculator.rate_type
         end
 
-        permitted_next_nodes = [
-          :nil_rate_result,
-          :flat_rate_result,
-          :reduced_and_basic_rates_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case rate_type
           when :nil
-            :nil_rate_result
+            outcome :nil_rate_result
           when :flat
-            :flat_rate_result
+            outcome :flat_rate_result
           else
-            :reduced_and_basic_rates_result
+            outcome :reduced_and_basic_rates_result
           end
         end
       end
diff --git a/test/data/calculate-your-child-maintenance-files.yml b/test/data/calculate-your-child-maintenance-files.yml
index 189fadbe046..2def0a16cd2 100644
--- a/test/data/calculate-your-child-maintenance-files.yml
+++ b/test/data/calculate-your-child-maintenance-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/calculate-your-child-maintenance.rb: b05aeb72fdad417824cadc0d184db5f8
+lib/smart_answer_flows/calculate-your-child-maintenance.rb: f867a79daff47a62e3c6a5b1c321ec7e
 test/data/calculate-your-child-maintenance-questions-and-responses.yml: 4534340cf82c2d7f24a865a8b70855fd
 test/data/calculate-your-child-maintenance-responses-and-expected-results.yml: e5f2d15987daf89c77c28fc4b4b82042
 lib/smart_answer_flows/calculate-your-child-maintenance/calculate_your_child_maintenance.govspeak.erb: 54774b8368ca04904d29c4857b8178ef

From fe10b84ead5c7586de42f2ed9be8c69f21aaf1a3 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 17:24:32 +0100
Subject: [PATCH 10/44] Automatic next_node detection in
 calculate-your-holiday-entitlement

---
 .../calculate-your-holiday-entitlement.rb     | 89 +++++++------------
 ...lculate-your-holiday-entitlement-files.yml |  2 +-
 2 files changed, 31 insertions(+), 60 deletions(-)

diff --git a/lib/smart_answer_flows/calculate-your-holiday-entitlement.rb b/lib/smart_answer_flows/calculate-your-holiday-entitlement.rb
index 7f0abc362bd..75ed9fdd869 100644
--- a/lib/smart_answer_flows/calculate-your-holiday-entitlement.rb
+++ b/lib/smart_answer_flows/calculate-your-holiday-entitlement.rb
@@ -26,25 +26,18 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :calculation_period?,
-          :casual_or_irregular_hours?,
-          :annualised_hours?,
-          :compressed_hours_how_many_hours_per_week?,
-          :shift_worker_basis?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'days-worked-per-week', 'hours-worked-per-week'
-            :calculation_period?
+            question :calculation_period?
           when 'casual-or-irregular-hours'
-            :casual_or_irregular_hours?
+            question :casual_or_irregular_hours?
           when 'annualised-hours'
-            :annualised_hours?
+            question :annualised_hours?
           when 'compressed-hours'
-            :compressed_hours_how_many_hours_per_week?
+            question :compressed_hours_how_many_hours_per_week?
           when 'shift-worker'
-            :shift_worker_basis?
+            question :shift_worker_basis?
           end
         end
       end
@@ -57,20 +50,18 @@ def define
         option "starting-and-leaving"
         save_input_as :holiday_period
 
-        permitted_next_nodes = [
-          :what_is_your_starting_date?,
-          :what_is_your_leaving_date?,
-          :how_many_days_per_week?,
-          :how_many_hours_per_week?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "starting", "starting-and-leaving"
-            :what_is_your_starting_date?
+            question :what_is_your_starting_date?
           when "leaving"
-            :what_is_your_leaving_date?
+            question :what_is_your_leaving_date?
           else
-            calculation_basis == "days-worked-per-week" ? :how_many_days_per_week? : :how_many_hours_per_week?
+            if calculation_basis == "days-worked-per-week"
+              question :how_many_days_per_week?
+            else
+              question :how_many_hours_per_week?
+            end
           end
         end
       end
@@ -91,15 +82,11 @@ def define
         to { Date.civil(1.year.since(Date.today).year, 12, 31) }
         save_input_as :start_date
 
-        permitted_next_nodes = [
-          :what_is_your_leaving_date?,
-          :when_does_your_leave_year_start?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if holiday_period == "starting-and-leaving"
-            :what_is_your_leaving_date?
+            question :what_is_your_leaving_date?
           else
-            :when_does_your_leave_year_start?
+            question :when_does_your_leave_year_start?
           end
         end
       end
@@ -110,24 +97,18 @@ def define
         to { Date.civil(1.year.since(Date.today).year, 12, 31) }
         save_input_as :leaving_date
 
-        permitted_next_nodes = [
-          :how_many_days_per_week?,
-          :how_many_hours_per_week?,
-          :shift_worker_hours_per_shift?,
-          :when_does_your_leave_year_start?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if holiday_period == "starting-and-leaving"
             case calculation_basis
             when "days-worked-per-week"
-              :how_many_days_per_week?
+              question :how_many_days_per_week?
             when "hours-worked-per-week"
-              :how_many_hours_per_week?
+              question :how_many_hours_per_week?
             when "shift-worker"
-              :shift_worker_hours_per_shift?
+              question :shift_worker_hours_per_shift?
             end
           else
-            :when_does_your_leave_year_start?
+            question :when_does_your_leave_year_start?
           end
         end
       end
@@ -138,19 +119,14 @@ def define
         to { Date.civil(1.year.since(Date.today).year, 12, 31) }
         save_input_as :leave_year_start_date
 
-        permitted_next_nodes = [
-          :how_many_days_per_week?,
-          :how_many_hours_per_week?,
-          :shift_worker_hours_per_shift?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case calculation_basis
           when "days-worked-per-week"
-            :how_many_days_per_week?
+            question :how_many_days_per_week?
           when "hours-worked-per-week"
-            :how_many_hours_per_week?
+            question :how_many_hours_per_week?
           when "shift-worker"
-            :shift_worker_hours_per_shift?
+            question :shift_worker_hours_per_shift?
           end
         end
       end
@@ -208,19 +184,14 @@ def define
         option "starting-and-leaving"
         save_input_as :holiday_period
 
-        permitted_next_nodes = [
-          :shift_worker_hours_per_shift?,
-          :what_is_your_starting_date?,
-          :what_is_your_leaving_date?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'full-year'
-            :shift_worker_hours_per_shift?
+            question :shift_worker_hours_per_shift?
           when 'starting', 'starting-and-leaving'
-            :what_is_your_starting_date?
+            question :what_is_your_starting_date?
           when 'leaving'
-            :what_is_your_leaving_date?
+            question :what_is_your_leaving_date?
           end
         end
       end
diff --git a/test/data/calculate-your-holiday-entitlement-files.yml b/test/data/calculate-your-holiday-entitlement-files.yml
index a4f4bd32215..c87f689155b 100644
--- a/test/data/calculate-your-holiday-entitlement-files.yml
+++ b/test/data/calculate-your-holiday-entitlement-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/calculate-your-holiday-entitlement.rb: ea477752bd44c3f1cfa092a7f0d8d891
+lib/smart_answer_flows/calculate-your-holiday-entitlement.rb: 1fafc80188b8ba55bf538a765208caaf
 test/data/calculate-your-holiday-entitlement-questions-and-responses.yml: a5d687911e6173e74f2b70af6a5ff7bd
 test/data/calculate-your-holiday-entitlement-responses-and-expected-results.yml: 5ff2290223d8188d45a84cde9883acf6
 lib/smart_answer_flows/calculate-your-holiday-entitlement/calculate_your_holiday_entitlement.govspeak.erb: 76f569916a2429d42e52afc658285f6a

From 3fdb477fab8ae2285a0e5b1ffc35804e5350f53e Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Thu, 10 Mar 2016 17:43:38 +0100
Subject: [PATCH 11/44] Automatic next_node detection in check-uk-visa

---
 lib/smart_answer_flows/check-uk-visa.rb | 137 ++++++++----------------
 test/data/check-uk-visa-files.yml       |   2 +-
 2 files changed, 47 insertions(+), 92 deletions(-)

diff --git a/lib/smart_answer_flows/check-uk-visa.rb b/lib/smart_answer_flows/check-uk-visa.rb
index f8675a515ec..d5351bd8536 100644
--- a/lib/smart_answer_flows/check-uk-visa.rb
+++ b/lib/smart_answer_flows/check-uk-visa.rb
@@ -18,19 +18,14 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :israeli_document_type?,
-          :outcome_no_visa_needed,
-          :purpose_of_visit?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.passport_country = response
           if calculator.passport_country_is_israel?
-            :israeli_document_type?
+            question :israeli_document_type?
           elsif calculator.passport_country_in_eea?
-            :outcome_no_visa_needed
+            outcome :outcome_no_visa_needed
           else
-            :purpose_of_visit?
+            question :purpose_of_visit?
           end
         end
       end
@@ -40,10 +35,9 @@ def define
         option :"full-passport"
         option :"provisional-passport"
 
-        permitted_next_nodes = [:purpose_of_visit?]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.passport_country = 'israel-provisional-passport' if response == 'provisional-passport'
-          :purpose_of_visit?
+          question :purpose_of_visit?
         end
       end
 
@@ -59,91 +53,73 @@ def define
         option :medical
         option :diplomatic
 
-        permitted_next_nodes = [
-          :outcome_diplomatic_business,
-          :outcome_joining_family_m,
-          :outcome_joining_family_nvn,
-          :outcome_joining_family_y,
-          :outcome_marriage,
-          :outcome_medical_n,
-          :outcome_medical_y,
-          :outcome_no_visa_needed,
-          :outcome_school_n,
-          :outcome_school_waiver,
-          :outcome_school_y,
-          :outcome_standard_visit,
-          :outcome_taiwan_exception,
-          :outcome_visit_waiver,
-          :passing_through_uk_border_control?,
-          :staying_for_how_long?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.purpose_of_visit_answer = response
 
           if calculator.study_visit? || calculator.work_visit?
-            next :staying_for_how_long?
+            next question(:staying_for_how_long?)
           end
 
           if calculator.diplomatic_visit?
-            next :outcome_diplomatic_business
+            next outcome(:outcome_diplomatic_business)
           end
 
           if calculator.school_visit?
             if calculator.passport_country_in_electronic_visa_waiver_list?
-              next :outcome_school_waiver
+              next outcome(:outcome_school_waiver)
             elsif calculator.passport_country_is_taiwan?
-              next :outcome_taiwan_exception
+              next outcome(:outcome_taiwan_exception)
             elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
-              next :outcome_school_n
+              next outcome(:outcome_school_n)
             else
-              next :outcome_school_y
+              next outcome(:outcome_school_y)
             end
           end
 
           if calculator.medical_visit?
             if calculator.passport_country_in_electronic_visa_waiver_list?
-              next :outcome_visit_waiver
+              next outcome(:outcome_visit_waiver)
             elsif calculator.passport_country_is_taiwan?
-              next :outcome_taiwan_exception
+              next outcome(:outcome_taiwan_exception)
             elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
-              next :outcome_medical_n
+              next outcome(:outcome_medical_n)
             else
-              next :outcome_medical_y
+              next outcome(:outcome_medical_y)
             end
           end
 
           if calculator.tourism_visit?
             if calculator.passport_country_in_electronic_visa_waiver_list?
-              next :outcome_visit_waiver
+              next outcome(:outcome_visit_waiver)
             elsif calculator.passport_country_is_taiwan?
-              next :outcome_taiwan_exception
+              next outcome(:outcome_taiwan_exception)
             elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
-              next :outcome_school_n # outcome does not contain school specific content
+              next outcome(:outcome_school_n) # outcome does not contain school specific content
             else
-              next :outcome_standard_visit
+              next outcome(:outcome_standard_visit)
             end
           end
 
           if calculator.marriage_visit?
-            next :outcome_marriage
+            next outcome(:outcome_marriage)
           end
 
           if calculator.transit_visit?
             if calculator.passport_country_in_datv_list? ||
                 calculator.passport_country_in_visa_national_list? || calculator.passport_country_is_taiwan? || calculator.passport_country_is_venezuela?
-              next :passing_through_uk_border_control?
+              next question(:passing_through_uk_border_control?)
             else
-              next :outcome_no_visa_needed
+              next outcome(:outcome_no_visa_needed)
             end
           end
 
           if calculator.family_visit?
             if calculator.passport_country_in_ukot_list?
-              next :outcome_joining_family_m
+              next outcome(:outcome_joining_family_m)
             elsif calculator.passport_country_in_non_visa_national_list?
-              next :outcome_joining_family_nvn
+              next outcome(:outcome_joining_family_nvn)
             else
-              next :outcome_joining_family_y
+              next outcome(:outcome_joining_family_y)
             end
           end
         end
@@ -154,38 +130,28 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :outcome_no_visa_needed,
-          :outcome_transit_leaving_airport,
-          :outcome_transit_leaving_airport_datv,
-          :outcome_transit_not_leaving_airport,
-          :outcome_transit_refugee_not_leaving_airport,
-          :outcome_transit_taiwan,
-          :outcome_transit_taiwan_through_border_control,
-          :outcome_transit_venezuela,
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.passing_through_uk_border_control_answer = response
 
           if calculator.passing_through_uk_border_control?
             if calculator.passport_country_is_taiwan?
-              :outcome_transit_taiwan_through_border_control
+              outcome :outcome_transit_taiwan_through_border_control
             elsif calculator.passport_country_in_visa_national_list?
-              :outcome_transit_leaving_airport
+              outcome :outcome_transit_leaving_airport
             elsif calculator.passport_country_in_datv_list?
-              :outcome_transit_leaving_airport_datv
+              outcome :outcome_transit_leaving_airport_datv
             end
           else
             if calculator.passport_country_is_taiwan?
-              :outcome_transit_taiwan
+              outcome :outcome_transit_taiwan
             elsif calculator.passport_country_is_venezuela?
-              :outcome_transit_venezuela
+              outcome :outcome_transit_venezuela
             elsif calculator.applicant_is_stateless_or_a_refugee?
-              :outcome_transit_refugee_not_leaving_airport
+              outcome :outcome_transit_refugee_not_leaving_airport
             elsif calculator.passport_country_in_datv_list?
-              :outcome_transit_not_leaving_airport
+              outcome :outcome_transit_not_leaving_airport
             elsif calculator.passport_country_in_visa_national_list?
-              :outcome_no_visa_needed
+              outcome :outcome_no_visa_needed
             end
           end
         end
@@ -204,46 +170,35 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :outcome_no_visa_needed,
-          :outcome_study_m,
-          :outcome_study_waiver,
-          :outcome_study_y,
-          :outcome_taiwan_exception,
-          :outcome_work_m,
-          :outcome_work_n,
-          :outcome_work_waiver,
-          :outcome_work_y
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'longer_than_six_months'
             if calculator.study_visit?
-              :outcome_study_y #outcome 2 study y
+              outcome :outcome_study_y #outcome 2 study y
             elsif calculator.work_visit?
-              :outcome_work_y #outcome 4 work y
+              outcome :outcome_work_y #outcome 4 work y
             end
           when 'six_months_or_less'
             if calculator.study_visit?
               if calculator.passport_country_in_electronic_visa_waiver_list?
-                :outcome_study_waiver
+                outcome :outcome_study_waiver
               elsif calculator.passport_country_is_taiwan?
-                :outcome_taiwan_exception
+                outcome :outcome_taiwan_exception
               elsif calculator.passport_country_in_datv_list? || calculator.passport_country_in_visa_national_list?
-                :outcome_study_m #outcome 3 study m visa needed short courses
+                outcome :outcome_study_m #outcome 3 study m visa needed short courses
               elsif calculator.passport_country_in_ukot_list? || calculator.passport_country_in_non_visa_national_list?
-                :outcome_no_visa_needed #outcome 1 no visa needed
+                outcome :outcome_no_visa_needed #outcome 1 no visa needed
               end
             elsif calculator.work_visit?
               if calculator.passport_country_in_electronic_visa_waiver_list?
-                :outcome_work_waiver
+                outcome :outcome_work_waiver
               elsif calculator.passport_country_in_ukot_list? ||
                   calculator.passport_country_is_taiwan? || calculator.passport_country_in_non_visa_national_list?
                 #outcome 5.5 work N no visa needed
-                :outcome_work_n
+                outcome :outcome_work_n
               elsif calculator.passport_country_in_datv_list? || calculator.passport_country_in_visa_national_list?
                 # outcome 5 work m visa needed short courses
-                :outcome_work_m
+                outcome :outcome_work_m
               end
             end
           end
diff --git a/test/data/check-uk-visa-files.yml b/test/data/check-uk-visa-files.yml
index e1047b349c3..6c57aa57c8b 100644
--- a/test/data/check-uk-visa-files.yml
+++ b/test/data/check-uk-visa-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/check-uk-visa.rb: 41158023166e66efe67de462fa653218
+lib/smart_answer_flows/check-uk-visa.rb: c459d4228d4d43f7f9ee088932638d31
 test/data/check-uk-visa-questions-and-responses.yml: db3081a2a7162f108baa5ff00706c9fd
 test/data/check-uk-visa-responses-and-expected-results.yml: 60d4090bdf290693442b66d5ab86102e
 lib/smart_answer_flows/check-uk-visa/check_uk_visa.govspeak.erb: a442b4ddd169b26a401c70d145e5b44e

From e677b483422d86a72af56e9459c3a2b265b99276 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Fri, 11 Mar 2016 18:49:21 +0100
Subject: [PATCH 12/44] Automatic next_node detection in
 childcare-costs-for-tax-credits

---
 .../childcare-costs-for-tax-credits.rb        | 129 ++++++------------
 .../childcare-costs-for-tax-credits-files.yml |   2 +-
 2 files changed, 39 insertions(+), 92 deletions(-)

diff --git a/lib/smart_answer_flows/childcare-costs-for-tax-credits.rb b/lib/smart_answer_flows/childcare-costs-for-tax-credits.rb
index 540538e9d61..344c527b6bf 100644
--- a/lib/smart_answer_flows/childcare-costs-for-tax-credits.rb
+++ b/lib/smart_answer_flows/childcare-costs-for-tax-credits.rb
@@ -15,16 +15,12 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :have_costs_changed?,
-          :how_often_use_childcare?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :have_costs_changed? #Q3
+            question :have_costs_changed? #Q3
           when 'no'
-            :how_often_use_childcare? #Q2
+            question :how_often_use_childcare? #Q2
           end
         end
       end
@@ -35,19 +31,14 @@ def define
         option :regularly_more_than_year
         option :only_short_while
 
-        permitted_next_nodes = [
-          :how_often_pay_1?,
-          :pay_same_each_time?,
-          :call_helpline_detailed
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'regularly_less_than_year'
-            :how_often_pay_1? #Q4
+            question :how_often_pay_1? #Q4
           when 'regularly_more_than_year'
-            :pay_same_each_time? #Q11
+            question :pay_same_each_time? #Q11
           when 'only_short_while'
-            :call_helpline_detailed #O1
+            outcome :call_helpline_detailed #O1
           end
         end
       end
@@ -57,16 +48,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :how_often_pay_2?,
-          :no_change
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_often_pay_2? #Q5
+            question :how_often_pay_2? #Q5
           when 'no'
-            :no_change #O2
+            outcome :no_change #O2
           end
         end
       end
@@ -79,22 +66,16 @@ def define
         option :monthly_diff_amount
         option :other
 
-        permitted_next_nodes = [
-          :round_up_weekly,
-          :how_much_52_weeks_1?,
-          :how_much_each_month?,
-          :how_much_12_months_1?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'weekly_same_amount'
-            :round_up_weekly #O3
+            question :round_up_weekly #O3
           when 'weekly_diff_amount'
-            :how_much_52_weeks_1? #Q7
+            question :how_much_52_weeks_1? #Q7
           when 'monthly_same_amount'
-            :how_much_each_month? #Q10
+            question :how_much_each_month? #Q10
           when 'monthly_diff_amount', 'other'
-            :how_much_12_months_1? #Q6
+            question :how_much_12_months_1? #Q6
           end
         end
       end
@@ -107,22 +88,16 @@ def define
         option :monthly_diff_amount
         option :other
 
-        permitted_next_nodes = [
-          :new_weekly_costs?,
-          :how_much_52_weeks_2?,
-          :new_monthly_cost?,
-          :how_much_12_months_2?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'weekly_same_amount'
-            :new_weekly_costs? #Q17
+            question :new_weekly_costs? #Q17
           when 'weekly_diff_amount', 'other'
-            :how_much_52_weeks_2? #Q8
+            question :how_much_52_weeks_2? #Q8
           when 'monthly_same_amount'
-            :new_monthly_cost? #Q19
+            question :new_monthly_cost? #Q19
           when 'monthly_diff_amount'
-            :how_much_12_months_2? #Q9
+            question :how_much_12_months_2? #Q9
           end
         end
       end
@@ -149,13 +124,9 @@ def define
           SmartAnswer::Calculators::ChildcareCostCalculator.weekly_cost(response)
         end
 
-        permitted_next_nodes = [
-          :no_longer_paying,
-          :old_weekly_amount_1?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           amount = Money.new(response)
-          amount == 0 ? :no_longer_paying : :old_weekly_amount_1?
+          amount == 0 ? outcome(:no_longer_paying) : question(:old_weekly_amount_1?)
         end
       end
 
@@ -165,13 +136,9 @@ def define
           SmartAnswer::Calculators::ChildcareCostCalculator.weekly_cost(response)
         end
 
-        permitted_next_nodes = [
-          :no_longer_paying,
-          :old_weekly_amount_1?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           amount = Money.new(response)
-          amount == 0 ? :no_longer_paying : :old_weekly_amount_1?
+          amount == 0 ? outcome(:no_longer_paying) : question(:old_weekly_amount_1?)
         end
       end
 
@@ -188,16 +155,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :how_often_pay_providers?,
-          :how_much_spent_last_12_months?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_often_pay_providers? #Q12
+            question :how_often_pay_providers? #Q12
           when 'no'
-            :how_much_spent_last_12_months? #Q16
+            question :how_much_spent_last_12_months? #Q16
           end
         end
       end
@@ -212,28 +175,20 @@ def define
         option :yearly
         option :other
 
-        permitted_next_nodes = [
-          :round_up_weekly,
-          :how_much_fortnightly?,
-          :how_much_4_weeks?,
-          :how_much_each_month?,
-          :call_helpline_plain,
-          :how_much_yearly?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'weekly'
-            :round_up_weekly #O3
+            outcome :round_up_weekly #O3
           when 'fortnightly'
-            :how_much_fortnightly? #Q13
+            question :how_much_fortnightly? #Q13
           when 'every_4_weeks'
-            :how_much_4_weeks? #Q14
+            question :how_much_4_weeks? #Q14
           when 'every_month'
-            :how_much_each_month? #Q10
+            question :how_much_each_month? #Q10
           when 'termly', 'other'
-            :call_helpline_plain #O5
+            outcome :call_helpline_plain #O5
           when 'yearly'
-            :how_much_yearly? #Q15
+            question :how_much_yearly? #Q15
           end
         end
       end
@@ -277,13 +232,9 @@ def define
           Float(response).ceil
         end
 
-        permitted_next_nodes = [
-          :no_longer_paying,
-          :old_weekly_amount_2?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           amount = Money.new(response)
-          amount == 0 ? :no_longer_paying : :old_weekly_amount_2?
+          amount == 0 ? outcome(:no_longer_paying) : question(:old_weekly_amount_2?)
         end
       end
 
@@ -312,13 +263,9 @@ def define
           SmartAnswer::Calculators::ChildcareCostCalculator.weekly_cost_from_monthly(response)
         end
 
-        permitted_next_nodes = [
-          :no_longer_paying,
-          :old_weekly_amount_3?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           amount = Money.new(response)
-          amount == 0 ? :no_longer_paying : :old_weekly_amount_3?
+          amount == 0 ? outcome(:no_longer_paying) : question(:old_weekly_amount_3?)
         end
       end
 
diff --git a/test/data/childcare-costs-for-tax-credits-files.yml b/test/data/childcare-costs-for-tax-credits-files.yml
index f8c3c7bd27b..bb0b68482d8 100644
--- a/test/data/childcare-costs-for-tax-credits-files.yml
+++ b/test/data/childcare-costs-for-tax-credits-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/childcare-costs-for-tax-credits.rb: fc8ca281e8befc0a28a51e0cab019a1b
+lib/smart_answer_flows/childcare-costs-for-tax-credits.rb: fad366affaa98710ad49af5fb8ae1739
 test/data/childcare-costs-for-tax-credits-questions-and-responses.yml: 626012bfcc3d89170729eb2140fc1aa4
 test/data/childcare-costs-for-tax-credits-responses-and-expected-results.yml: 37aa1c49681770c252fd9ca273d1ba07
 lib/smart_answer_flows/childcare-costs-for-tax-credits/childcare_costs_for_tax_credits.govspeak.erb: b9067a0397fac45150cfc4b5a3174b25

From da49cac05297afef68f47d1a098a5b7c102cf8b6 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Fri, 11 Mar 2016 19:00:09 +0100
Subject: [PATCH 13/44] Automatic next_node detection in
 energy-grants-calculator

---
 .../energy-grants-calculator.rb               | 143 ++++++------------
 test/data/energy-grants-calculator-files.yml  |   2 +-
 2 files changed, 46 insertions(+), 99 deletions(-)

diff --git a/lib/smart_answer_flows/energy-grants-calculator.rb b/lib/smart_answer_flows/energy-grants-calculator.rb
index bf61a184075..9749065802d 100644
--- a/lib/smart_answer_flows/energy-grants-calculator.rb
+++ b/lib/smart_answer_flows/energy-grants-calculator.rb
@@ -44,16 +44,12 @@ def define
           ''
         end
 
-        permitted_next_nodes = [
-          :what_are_your_circumstances?,
-          :what_are_your_circumstances_without_bills_help?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'help_with_fuel_bill'
-            :what_are_your_circumstances? # Q2
+            question :what_are_your_circumstances? # Q2
           else
-            :what_are_your_circumstances_without_bills_help? # Q2A
+            question :what_are_your_circumstances_without_bills_help? # Q2A
           end
         end
       end
@@ -101,19 +97,14 @@ def define
           %w(help_energy_efficiency help_boiler_measure).include?(which_help)
         }
 
-        permitted_next_nodes = [
-          :date_of_birth?,
-          :which_benefits?,
-          :when_property_built?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if both_help
-            :date_of_birth?
+            question :date_of_birth?
           elsif measure
             if response == 'benefits'
-              :which_benefits?
+              question :which_benefits?
             else
-              :when_property_built?
+              question :when_property_built?
             end
           end
         end
@@ -132,18 +123,13 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :which_benefits?,
-          :outcome_help_with_bills,
-          :when_property_built?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if circumstances.include?('benefits')
-            :which_benefits?
+            question :which_benefits?
           elsif bills_help
-            :outcome_help_with_bills # outcome 1
+            outcome :outcome_help_with_bills # outcome 1
           else
-            :when_property_built? # Q6
+            question :when_property_built? # Q6
           end
         end
       end
@@ -180,24 +166,19 @@ def define
             %w{child_tax_credit esa jsa pension_credit}.all? {|key| response.include? key}
         end
 
-        permitted_next_nodes = [
-          :outcome_help_with_bills,
-          :when_property_built?,
-          :disabled_or_have_children?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if %w{pension_credit child_tax_credit}.include?(response)
             if bills_help
-              :outcome_help_with_bills # outcome 1
+              outcome :outcome_help_with_bills # outcome 1
             else
-              :when_property_built? # Q6
+              question :when_property_built? # Q6
             end
           elsif disabled_or_have_children_question
-            :disabled_or_have_children? # Q5
+            question :disabled_or_have_children? # Q5
           elsif bills_help
-            :outcome_help_with_bills # outcome 1
+            outcome :outcome_help_with_bills # outcome 1
           else
-            :when_property_built? # Q6
+            question :when_property_built? # Q6
           end
         end
       end
@@ -232,15 +213,11 @@ def define
           response != 'none' && benefits_claimed.include?('universal_credit')
         end
 
-        permitted_next_nodes = [
-          :outcome_help_with_bills,
-          :when_property_built?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if bills_help
-            :outcome_help_with_bills # outcome 1
+            outcome :outcome_help_with_bills # outcome 1
           else
-            :when_property_built? # Q6
+            question :when_property_built? # Q6
           end
         end
       end
@@ -271,24 +248,18 @@ def define
         option :flat
         save_input_as :property_type
 
-        permitted_next_nodes = [
-          :home_features_modern?,
-          :home_features_older?,
-          :home_features_historic?,
-          :type_of_flat?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'house'
             if modern
-              :home_features_modern?
+              question :home_features_modern?
             elsif older
-              :home_features_older?
+              question :home_features_older?
             else
-              :home_features_historic?
+              question :home_features_historic?
             end
           else
-            :type_of_flat?
+            question :type_of_flat?
           end
         end
       end
@@ -299,18 +270,13 @@ def define
         option :ground_floor
         save_input_as :flat_type
 
-        permitted_next_nodes = [
-          :home_features_modern?,
-          :home_features_older?,
-          :home_features_historic?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if modern
-            :home_features_modern?
+            question :home_features_modern?
           elsif older
-            :home_features_older?
+            question :home_features_older?
           else
-            :home_features_historic?
+            question :home_features_historic?
           end
         end
       end
@@ -340,24 +306,17 @@ def define
           (circumstances & %w(property permission)).any? and ((benefits_claimed & %w(child_tax_credit esa pension_credit)).any? or incomesupp_jobseekers_1 or incomesupp_jobseekers_2)
         end
 
-        permitted_next_nodes = [
-          :outcome_no_green_deal_no_energy_measures,
-          :outcome_measures_help_green_deal,
-          :outcome_bills_and_measures_no_benefits,
-          :outcome_bills_and_measures_on_benefits_eco_eligible,
-          :outcome_bills_and_measures_on_benefits_not_eco_eligible
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if modern_and_gas_and_electric_heating
-            :outcome_no_green_deal_no_energy_measures
+            outcome :outcome_no_green_deal_no_energy_measures
           elsif measure_help_and_property_permission_circumstance
-            :outcome_measures_help_green_deal
+            outcome :outcome_measures_help_green_deal
           elsif no_benefits
-            :outcome_bills_and_measures_no_benefits
+            outcome :outcome_bills_and_measures_no_benefits
           elsif property_permission_circumstance_and_benefits
-            :outcome_bills_and_measures_on_benefits_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_eco_eligible
           else
-            :outcome_bills_and_measures_on_benefits_not_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_not_eco_eligible
           end
         end
       end
@@ -387,21 +346,15 @@ def define
           (circumstances & %w(property permission)).any? and ((benefits_claimed & %w(child_tax_credit esa pension_credit)).any? or incomesupp_jobseekers_1 or incomesupp_jobseekers_2)
         end
 
-        permitted_next_nodes = [
-          :outcome_measures_help_green_deal,
-          :outcome_bills_and_measures_no_benefits,
-          :outcome_bills_and_measures_on_benefits_eco_eligible,
-          :outcome_bills_and_measures_on_benefits_not_eco_eligible
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if measure_help_and_property_permission_circumstance
-            :outcome_measures_help_green_deal
+            outcome :outcome_measures_help_green_deal
           elsif no_benefits
-            :outcome_bills_and_measures_no_benefits
+            outcome :outcome_bills_and_measures_no_benefits
           elsif property_permission_circumstance_and_benefits
-            :outcome_bills_and_measures_on_benefits_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_eco_eligible
           else
-            :outcome_bills_and_measures_on_benefits_not_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_not_eco_eligible
           end
         end
       end
@@ -432,21 +385,15 @@ def define
           (circumstances & %w(property permission)).any? and ((benefits_claimed & %w(child_tax_credit esa pension_credit)).any? or incomesupp_jobseekers_1 or incomesupp_jobseekers_2)
         end
 
-        permitted_next_nodes = [
-          :outcome_measures_help_green_deal,
-          :outcome_bills_and_measures_no_benefits,
-          :outcome_bills_and_measures_on_benefits_eco_eligible,
-          :outcome_bills_and_measures_on_benefits_not_eco_eligible
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if measure_help_and_property_permission_circumstance
-            :outcome_measures_help_green_deal
+            outcome :outcome_measures_help_green_deal
           elsif no_benefits
-            :outcome_bills_and_measures_no_benefits
+            outcome :outcome_bills_and_measures_no_benefits
           elsif property_permission_circumstance_and_benefits
-            :outcome_bills_and_measures_on_benefits_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_eco_eligible
           else
-            :outcome_bills_and_measures_on_benefits_not_eco_eligible
+            outcome :outcome_bills_and_measures_on_benefits_not_eco_eligible
           end
         end
       end
diff --git a/test/data/energy-grants-calculator-files.yml b/test/data/energy-grants-calculator-files.yml
index 6dbe2030612..905fc638b83 100644
--- a/test/data/energy-grants-calculator-files.yml
+++ b/test/data/energy-grants-calculator-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/energy-grants-calculator.rb: 7649654aef35c26316210e41a3600fee
+lib/smart_answer_flows/energy-grants-calculator.rb: 88b64a126c9ffa5088f33a6cd5c059c9
 test/data/energy-grants-calculator-questions-and-responses.yml: e725aa49320518369f4fdc601cd217b2
 test/data/energy-grants-calculator-responses-and-expected-results.yml: 8b1d6c6350f162a2d4efbc65362b5ae8
 lib/smart_answer_flows/energy-grants-calculator/energy_grants_calculator.govspeak.erb: 7df3ca7bdc65c932d84c51b4bd742bc2

From a4b0dd4fd14ac3256e54f52efee24d265cd22698 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 10:59:01 +0100
Subject: [PATCH 14/44] Automatic next_node detection in
 estimate-self-assessment-penalties

---
 .../estimate-self-assessment-penalties.rb         | 15 +++++----------
 .../estimate-self-assessment-penalties-files.yml  |  2 +-
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lib/smart_answer_flows/estimate-self-assessment-penalties.rb b/lib/smart_answer_flows/estimate-self-assessment-penalties.rb
index 65b8e8afbca..674f9831604 100644
--- a/lib/smart_answer_flows/estimate-self-assessment-penalties.rb
+++ b/lib/smart_answer_flows/estimate-self-assessment-penalties.rb
@@ -75,12 +75,11 @@ def define
           filing_date.strftime("%e %B %Y")
         end
 
-        permitted_next_nodes = [:when_paid?]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response < start_of_next_tax_year
             raise SmartAnswer::InvalidResponse
           else
-            :when_paid?
+            question :when_paid?
           end
         end
       end
@@ -91,11 +90,7 @@ def define
 
         save_input_as :payment_date
 
-        permitted_next_nodes = [
-          :filed_and_paid_on_time,
-          :how_much_tax?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if filing_date > response
             raise SmartAnswer::InvalidResponse
           else
@@ -107,9 +102,9 @@ def define
               tax_year: tax_year
             )
             if calculator.paid_on_time?
-              :filed_and_paid_on_time
+              outcome :filed_and_paid_on_time
             else
-              :how_much_tax?
+              question :how_much_tax?
             end
           end
         end
diff --git a/test/data/estimate-self-assessment-penalties-files.yml b/test/data/estimate-self-assessment-penalties-files.yml
index 9082d9f610c..de54c5a9da7 100644
--- a/test/data/estimate-self-assessment-penalties-files.yml
+++ b/test/data/estimate-self-assessment-penalties-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/estimate-self-assessment-penalties.rb: c47d2f6098e596060052001c45035e96
+lib/smart_answer_flows/estimate-self-assessment-penalties.rb: dcff78ee870b1a29eed5d08c93f6d5fc
 test/data/estimate-self-assessment-penalties-questions-and-responses.yml: 186d93854ea5dc9321408e14dcc8d61f
 test/data/estimate-self-assessment-penalties-responses-and-expected-results.yml: 4da19a0a153e226139199a1b393de4e9
 lib/smart_answer_flows/estimate-self-assessment-penalties/estimate_self_assessment_penalties.govspeak.erb: d35eaf0334a9e871fa14294682fb7322

From 0fec0b2ccc639500f2bd3ffe67de2a3c4b90fba4 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:09:17 +0100
Subject: [PATCH 15/44] Automatic next_node detection in
 help-if-you-are-arrested-abroad

---
 .../help-if-you-are-arrested-abroad.rb              | 13 ++++---------
 test/data/help-if-you-are-arrested-abroad-files.yml |  2 +-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb b/lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb
index e80bfe6d887..3cb89b3860d 100644
--- a/lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb
+++ b/lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb
@@ -77,18 +77,13 @@ def define
           links
         end
 
-        permitted_next_nodes = [
-          :answer_two_iran,
-          :answer_three_syria,
-          :answer_one_generic
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == "iran"
-            :answer_two_iran
+            outcome :answer_two_iran
           elsif response == "syria"
-            :answer_three_syria
+            outcome :answer_three_syria
           else
-            :answer_one_generic
+            outcome :answer_one_generic
           end
         end
 
diff --git a/test/data/help-if-you-are-arrested-abroad-files.yml b/test/data/help-if-you-are-arrested-abroad-files.yml
index fdaa8adbc98..7db86b9ee9b 100644
--- a/test/data/help-if-you-are-arrested-abroad-files.yml
+++ b/test/data/help-if-you-are-arrested-abroad-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb: cc7831e704176ed0a3545425c6e08f2e
+lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb: 01387b1162781a8d4fca93337ca46c76
 test/data/help-if-you-are-arrested-abroad-questions-and-responses.yml: c007b0dd259d1c09ccc2dd3163fa1e56
 test/data/help-if-you-are-arrested-abroad-responses-and-expected-results.yml: 3e3aeca8a1af7c147b8f62af365f650d
 lib/smart_answer_flows/help-if-you-are-arrested-abroad/help_if_you_are_arrested_abroad.govspeak.erb: cb923645274b287ba93af8c7118d7f88

From a89fa66bb6add217cd83554dbebaf88ee873aead Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:16:25 +0100
Subject: [PATCH 16/44] Automatic next_node detection in
 inherits-someone-dies-without-will

---
 .../inherits-someone-dies-without-will.rb     | 211 ++++++------------
 ...herits-someone-dies-without-will-files.yml |   2 +-
 2 files changed, 73 insertions(+), 140 deletions(-)

diff --git a/lib/smart_answer_flows/inherits-someone-dies-without-will.rb b/lib/smart_answer_flows/inherits-someone-dies-without-will.rb
index 5e62bcbaa41..8b6a5266a90 100644
--- a/lib/smart_answer_flows/inherits-someone-dies-without-will.rb
+++ b/lib/smart_answer_flows/inherits-someone-dies-without-will.rb
@@ -31,21 +31,17 @@ def define
 
         save_input_as :partner
 
-        permitted_next_nodes = [
-          :children?,
-          :estate_over_250000?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales', 'northern-ireland'
             case response
             when 'yes'
-              :estate_over_250000?
+              question :estate_over_250000?
             when 'no'
-              :children?
+              question :children?
             end
           when 'scotland'
-            :children?
+            question :children?
           end
         end
       end
@@ -65,26 +61,21 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :outcome_1,
-          :outcome_60,
-          :children?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case response
             when 'yes'
-              :children?
+              question :children?
             when 'no'
-              :outcome_1
+              outcome :outcome_1
             end
           when 'northern-ireland'
             case response
             when 'yes'
-              :children?
+              question :children?
             when 'no'
-              :outcome_60
+              outcome :outcome_60
             end
           end
         end
@@ -97,32 +88,23 @@ def define
 
         save_input_as :children
 
-        permitted_next_nodes = [
-          :outcome_1,
-          :outcome_2,
-          :outcome_20,
-          :outcome_40,
-          :outcome_66,
-          :more_than_one_child?,
-          :parents?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case partner
             when 'yes'
               case response
               when 'yes'
-                :outcome_20
+                outcome :outcome_20
               when 'no'
-                :outcome_1
+                outcome :outcome_1
               end
             when 'no'
               case response
               when 'yes'
-                :outcome_2
+                outcome :outcome_2
               when 'no'
-                :parents?
+                question :parents?
               end
             end
           when 'scotland'
@@ -130,16 +112,16 @@ def define
             when 'yes'
               case response
               when 'yes'
-                :outcome_40
+                outcome :outcome_40
               when 'no'
-                :parents?
+                question :parents?
               end
             when 'no'
               case response
               when 'yes'
-                :outcome_2
+                outcome :outcome_2
               when 'no'
-                :parents?
+                question :parents?
               end
             end
           when 'northern-ireland'
@@ -147,16 +129,16 @@ def define
             when 'yes'
               case response
               when 'yes'
-                :more_than_one_child?
+                question :more_than_one_child?
               when 'no'
-                :parents?
+                question :parents?
               end
             when 'no'
               case response
               when 'yes'
-                :outcome_66
+                outcome :outcome_66
               when 'no'
-                :parents?
+                question :parents?
               end
             end
           end
@@ -170,38 +152,32 @@ def define
 
         save_input_as :parents
 
-        permitted_next_nodes = [
-          :outcome_3,
-          :outcome_63,
-          :siblings?,
-          :siblings_including_mixed_parents?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case response
             when 'yes'
-              :outcome_3
+              outcome :outcome_3
             when 'no'
-              :siblings?
+              question :siblings?
             end
           when 'scotland'
-            :siblings?
+            question :siblings?
           when 'northern-ireland'
             case partner
             when 'yes'
               case response
               when 'yes'
-                :outcome_63
+                outcome :outcome_63
               when 'no'
-                :siblings_including_mixed_parents?
+                question :siblings_including_mixed_parents?
               end
             when 'no'
               case response
               when 'yes'
-                :outcome_3
+                outcome :outcome_3
               when 'no'
-                :siblings?
+                question :siblings?
               end
             end
           end
@@ -215,26 +191,14 @@ def define
 
         save_input_as :siblings
 
-        permitted_next_nodes = [
-          :outcome_1,
-          :outcome_3,
-          :outcome_4,
-          :outcome_41,
-          :outcome_42,
-          :outcome_43,
-          :outcome_44,
-          :aunts_or_uncles?,
-          :grandparents?,
-          :half_siblings?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case response
             when 'yes'
-              :outcome_4
+              outcome :outcome_4
             when 'no'
-              :half_siblings?
+              question :half_siblings?
             end
           when 'scotland'
             case partner
@@ -243,16 +207,16 @@ def define
               when 'yes'
                 case response
                 when 'yes'
-                  :outcome_43
+                  outcome :outcome_43
                 when 'no'
-                  :outcome_42
+                  outcome :outcome_42
                 end
               when 'no'
                 case response
                 when 'yes'
-                  :outcome_41
+                  outcome :outcome_41
                 when 'no'
-                  :outcome_1
+                  outcome :outcome_1
                 end
               end
             when 'no'
@@ -260,25 +224,25 @@ def define
               when 'yes'
                 case response
                 when 'yes'
-                  :outcome_44
+                  outcome :outcome_44
                 when 'no'
-                  :outcome_3
+                  outcome :outcome_3
                 end
               when 'no'
                 case response
                 when 'yes'
-                  :outcome_4
+                  outcome :outcome_4
                 when 'no'
-                  :aunts_or_uncles?
+                  question :aunts_or_uncles?
                 end
               end
             end
           when 'northern-ireland'
             case response
             when 'yes'
-              :outcome_4
+              outcome :outcome_4
             when 'no'
-              :grandparents?
+              question :grandparents?
             end
           end
         end
@@ -291,16 +255,12 @@ def define
 
         save_input_as :siblings
 
-        permitted_next_nodes = [
-          :outcome_64,
-          :outcome_65
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :outcome_64
+            outcome :outcome_64
           when 'no'
-            :outcome_65
+            outcome :outcome_65
           end
         end
       end
@@ -312,33 +272,28 @@ def define
 
         save_input_as :grandparents
 
-        permitted_next_nodes = [
-          :outcome_5,
-          :aunts_or_uncles?,
-          :great_aunts_or_uncles?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case response
             when 'yes'
-              :outcome_5
+              outcome :outcome_5
             when 'no'
-              :aunts_or_uncles?
+              question :aunts_or_uncles?
             end
           when 'scotland'
             case response
             when 'yes'
-              :outcome_5
+              outcome :outcome_5
             when 'no'
-              :great_aunts_or_uncles?
+              question :great_aunts_or_uncles?
             end
           when 'northern-ireland'
             case response
             when 'yes'
-              :outcome_5
+              outcome :outcome_5
             when 'no'
-              :aunts_or_uncles?
+              question :aunts_or_uncles?
             end
           end
         end
@@ -351,34 +306,28 @@ def define
 
         save_input_as :aunts_or_uncles
 
-        permitted_next_nodes = [
-          :outcome_6,
-          :outcome_67,
-          :grandparents?,
-          :half_aunts_or_uncles?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case region
           when 'england-and-wales'
             case response
             when 'yes'
-              :outcome_6
+              outcome :outcome_6
             when 'no'
-              :half_aunts_or_uncles?
+              question :half_aunts_or_uncles?
             end
           when 'scotland'
             case response
             when 'yes'
-              :outcome_6
+              outcome :outcome_6
             when 'no'
-              :grandparents?
+              question :grandparents?
             end
           when 'northern-ireland'
             case response
             when 'yes'
-              :outcome_6
+              outcome :outcome_6
             when 'no'
-              :outcome_67
+              outcome :outcome_67
             end
           end
         end
@@ -391,16 +340,12 @@ def define
 
         save_input_as :half_siblings
 
-        permitted_next_nodes = [
-          :outcome_23,
-          :grandparents?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :outcome_23
+            outcome :outcome_23
           when 'no'
-            :grandparents?
+            question :grandparents?
           end
         end
       end
@@ -412,16 +357,12 @@ def define
 
         save_input_as :half_aunts_or_uncles
 
-        permitted_next_nodes = [
-          :outcome_24,
-          :outcome_25
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :outcome_24
+            outcome :outcome_24
           when 'no'
-            :outcome_25
+            outcome :outcome_25
           end
         end
       end
@@ -433,16 +374,12 @@ def define
 
         save_input_as :great_aunts_or_uncles
 
-        permitted_next_nodes = [
-          :outcome_45,
-          :outcome_46
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :outcome_45
+            outcome :outcome_45
           when 'no'
-            :outcome_46
+            outcome :outcome_46
           end
         end
       end
@@ -454,16 +391,12 @@ def define
 
         save_input_as :more_than_one_child
 
-        permitted_next_nodes = [
-          :outcome_61,
-          :outcome_62
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :outcome_61
+            outcome :outcome_61
           when 'no'
-            :outcome_62
+            outcome :outcome_62
           end
         end
       end
diff --git a/test/data/inherits-someone-dies-without-will-files.yml b/test/data/inherits-someone-dies-without-will-files.yml
index 7b1aa76fe47..7f9b17af3a5 100644
--- a/test/data/inherits-someone-dies-without-will-files.yml
+++ b/test/data/inherits-someone-dies-without-will-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/inherits-someone-dies-without-will.rb: 99c6646a6bc0ab5542d223565f3d76ed
+lib/smart_answer_flows/inherits-someone-dies-without-will.rb: 64e80a0475c67a9ae5dbd706be91a4de
 test/data/inherits-someone-dies-without-will-questions-and-responses.yml: a57baf7adb75b1513fd14bcc6147e03d
 test/data/inherits-someone-dies-without-will-responses-and-expected-results.yml: 490480b788e6cb1108a281db037e3ee6
 lib/smart_answer_flows/inherits-someone-dies-without-will/inherits_someone_dies_without_will.govspeak.erb: 7fc6ac5b4ca2ce72cd3e81e352596f19

From eb54fe012a1e27fb319f2cf939cc9894488baf33 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:21:01 +0100
Subject: [PATCH 17/44] Automatic next_node detection in
 landlord-immigration-check

---
 .../landlord-immigration-check.rb             | 162 ++++++------------
 .../data/landlord-immigration-check-files.yml |   2 +-
 2 files changed, 50 insertions(+), 114 deletions(-)

diff --git a/lib/smart_answer_flows/landlord-immigration-check.rb b/lib/smart_answer_flows/landlord-immigration-check.rb
index 80169e51c33..d0095b82b07 100644
--- a/lib/smart_answer_flows/landlord-immigration-check.rb
+++ b/lib/smart_answer_flows/landlord-immigration-check.rb
@@ -7,20 +7,15 @@ def define
       satisfies_need "102373"
 
       postcode_question :property? do
-        permitted_next_nodes = [
-          :main_home?,
-          :outcome_check_not_needed
-        ]
-
         next_node_calculation :calculator do |response|
           Calculators::LandlordImmigrationCheckCalculator.new(response)
         end
 
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if calculator.included_country?
-            :main_home?
+            question :main_home?
           else
-            :outcome_check_not_needed
+            outcome :outcome_check_not_needed
           end
         end
       end
@@ -29,16 +24,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :tenant_over_18?,
-          :property_type?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :tenant_over_18?
+            question :tenant_over_18?
           when "no"
-            :property_type?
+            question :property_type?
           end
         end
       end
@@ -47,16 +38,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :has_uk_passport?,
-          :outcome_check_not_needed_when_under_18
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :has_uk_passport?
+            question :has_uk_passport?
           when "no"
-            :outcome_check_not_needed_when_under_18
+            outcome :outcome_check_not_needed_when_under_18
           end
         end
       end
@@ -71,34 +58,24 @@ def define
         option "student_accommodation"
         option "7_year_lease_property"
 
-        permitted_next_nodes = [
-          :outcome_check_not_needed_if_holiday_or_under_3_months,
-          :outcome_check_not_needed,
-          :outcome_check_not_needed_when_care_home,
-          :outcome_check_not_needed_when_hostel_refuge,
-          :outcome_check_not_needed_when_mobile_home,
-          :outcome_check_not_needed_when_employee_home,
-          :outcome_check_may_be_needed_when_student,
-          :outcome_check_needed_if_break_clause
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "holiday_accommodation"
-            :outcome_check_not_needed_if_holiday_or_under_3_months
+            outcome :outcome_check_not_needed_if_holiday_or_under_3_months
           when "social_housing"
-            :outcome_check_not_needed
+            outcome :outcome_check_not_needed
           when "care_home"
-            :outcome_check_not_needed_when_care_home
+            outcome :outcome_check_not_needed_when_care_home
           when "hostel_or_refuge"
-            :outcome_check_not_needed_when_hostel_refuge
+            outcome :outcome_check_not_needed_when_hostel_refuge
           when "mobile_home"
-            :outcome_check_not_needed_when_mobile_home
+            outcome :outcome_check_not_needed_when_mobile_home
           when "employee_accommodation"
-            :outcome_check_not_needed_when_employee_home
+            outcome :outcome_check_not_needed_when_employee_home
           when "student_accommodation"
-            :outcome_check_may_be_needed_when_student
+            outcome :outcome_check_may_be_needed_when_student
           when "7_year_lease_property"
-            :outcome_check_needed_if_break_clause
+            outcome :outcome_check_needed_if_break_clause
           end
         end
       end
@@ -107,16 +84,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :right_to_abode?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :right_to_abode?
+            question :right_to_abode?
           end
         end
       end
@@ -125,16 +98,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :has_certificate?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :has_certificate?
+            question :has_certificate?
           end
         end
       end
@@ -143,16 +112,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :tenant_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :tenant_country?
+            question :tenant_country?
           end
         end
       end
@@ -162,19 +127,14 @@ def define
         option "non_eea_but_with_eu_eea_switzerland_family_member"
         option "somewhere_else"
 
-        permitted_next_nodes = [
-          :has_documents?,
-          :has_residence_card_or_eu_eea_swiss_family_member?,
-          :has_other_documents?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "eu_eea_switzerland"
-            :has_documents?
+            question :has_documents?
           when "non_eea_but_with_eu_eea_switzerland_family_member"
-            :has_residence_card_or_eu_eea_swiss_family_member?
+            question :has_residence_card_or_eu_eea_swiss_family_member?
           when "somewhere_else"
-            :has_other_documents?
+            question :has_other_documents?
           end
         end
       end
@@ -183,16 +143,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :has_other_documents?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :has_other_documents?
+            question :has_other_documents?
           end
         end
       end
@@ -201,16 +157,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :time_limited_to_remain?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :time_limited_to_remain?
+            question :time_limited_to_remain?
           end
         end
       end
@@ -219,16 +171,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent_for_12_months,
-          :immigration_application?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent_for_12_months
+            outcome :outcome_can_rent_for_12_months
           when "no"
-            :immigration_application?
+            question :immigration_application?
           end
         end
       end
@@ -237,16 +185,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent_but_check_will_be_needed_again,
-          :has_residence_card_or_eu_eea_swiss_family_member?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent_but_check_will_be_needed_again
+            outcome :outcome_can_rent_but_check_will_be_needed_again
           when "no"
-            :has_residence_card_or_eu_eea_swiss_family_member?
+            question :has_residence_card_or_eu_eea_swiss_family_member?
           end
         end
       end
@@ -255,16 +199,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent_for_12_months,
-          :outcome_can_not_rent
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent_for_12_months
+            outcome :outcome_can_rent_for_12_months
           when "no"
-            :outcome_can_not_rent
+            outcome :outcome_can_not_rent
           end
         end
       end
@@ -273,16 +213,12 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :outcome_can_rent,
-          :has_asylum_card?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when "yes"
-            :outcome_can_rent
+            outcome :outcome_can_rent
           when "no"
-            :has_asylum_card?
+            question :has_asylum_card?
           end
         end
       end
diff --git a/test/data/landlord-immigration-check-files.yml b/test/data/landlord-immigration-check-files.yml
index d16dec5bc06..144e6f937cc 100644
--- a/test/data/landlord-immigration-check-files.yml
+++ b/test/data/landlord-immigration-check-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/landlord-immigration-check.rb: c254f6b85c1b958ac2993665801690e7
+lib/smart_answer_flows/landlord-immigration-check.rb: 484295a5969844e7a17ee3b6c4b8e326
 test/data/landlord-immigration-check-questions-and-responses.yml: d4b485131540c40211b26a50e071032d
 test/data/landlord-immigration-check-responses-and-expected-results.yml: 7982d80c9851bfa7e55dbee4661e70bc
 lib/smart_answer_flows/landlord-immigration-check/landlord_immigration_check.govspeak.erb: 60507bfc657cf13a750b258017453743

From 06c84bec9ea9944842dbc5de4e9dab73b5f8fe19 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:32:22 +0100
Subject: [PATCH 18/44] Automatic next_node detection in marriage-abroad

---
 lib/smart_answer_flows/marriage-abroad.rb | 172 ++++++++--------------
 test/data/marriage-abroad-files.yml       |   2 +-
 2 files changed, 60 insertions(+), 114 deletions(-)

diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb
index 16c1e6cb336..e8082c202f8 100644
--- a/lib/smart_answer_flows/marriage-abroad.rb
+++ b/lib/smart_answer_flows/marriage-abroad.rb
@@ -23,22 +23,16 @@ def define
           Calculators::MarriageAbroadCalculator.new
         end
 
-        permitted_next_nodes = [
-          :legal_residency?,
-          :marriage_or_pacs?,
-          :outcome_os_france_or_fot,
-          :partner_opposite_or_same_sex?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.ceremony_country = response
           if calculator.ceremony_country == 'ireland'
-            :partner_opposite_or_same_sex?
+            question :partner_opposite_or_same_sex?
           elsif %w(france monaco new-caledonia wallis-and-futuna).include?(calculator.ceremony_country)
-            :marriage_or_pacs?
+            question :marriage_or_pacs?
           elsif calculator.ceremony_country_is_french_overseas_territory?
-            :outcome_os_france_or_fot
+            outcome :outcome_os_france_or_fot
           else
-            :legal_residency?
+            question :legal_residency?
           end
         end
       end
@@ -49,16 +43,12 @@ def define
         option :ceremony_country
         option :third_country
 
-        permitted_next_nodes = [
-          :partner_opposite_or_same_sex?,
-          :what_is_your_partners_nationality?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.resident_of = response
           if calculator.ceremony_country == 'switzerland'
-            :partner_opposite_or_same_sex?
+            question :partner_opposite_or_same_sex?
           else
-            :what_is_your_partners_nationality?
+            question :what_is_your_partners_nationality?
           end
         end
       end
@@ -68,19 +58,14 @@ def define
         option :marriage
         option :pacs
 
-        permitted_next_nodes = [
-          :outcome_cp_france_pacs,
-          :outcome_monaco,
-          :outcome_os_france_or_fot
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.marriage_or_pacs = response
           if calculator.ceremony_country == 'monaco'
-            :outcome_monaco
+            outcome :outcome_monaco
           elsif calculator.want_to_get_married?
-            :outcome_os_france_or_fot
+            outcome :outcome_os_france_or_fot
           else
-            :outcome_cp_france_pacs
+            outcome :outcome_cp_france_pacs
           end
         end
       end
@@ -91,9 +76,9 @@ def define
         option :partner_local
         option :partner_other
 
-        next_node(permitted: [:partner_opposite_or_same_sex?]) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.partner_nationality = response
-          :partner_opposite_or_same_sex?
+          question :partner_opposite_or_same_sex?
         end
       end
 
@@ -102,158 +87,119 @@ def define
         option :opposite_sex
         option :same_sex
 
-        permitted_next_nodes = [
-          :outcome_brazil_not_living_in_the_uk,
-          :outcome_consular_cni_os_residing_in_third_country,
-          :outcome_cp_all_other_countries,
-          :outcome_cp_commonwealth_countries,
-          :outcome_cp_consular,
-          :outcome_cp_no_cni,
-          :outcome_cp_or_equivalent,
-          :outcome_ireland,
-          :outcome_marriage_via_local_authorities,
-          :outcome_os_affirmation,
-          :outcome_os_belarus,
-          :outcome_os_bot,
-          :outcome_os_cambodia,
-          :outcome_os_colombia,
-          :outcome_os_commonwealth,
-          :outcome_os_consular_cni,
-          :outcome_os_germany,
-          :outcome_os_hong_kong,
-          :outcome_os_indonesia,
-          :outcome_os_italy,
-          :outcome_os_kosovo,
-          :outcome_os_kuwait,
-          :outcome_os_laos,
-          :outcome_os_japan,
-          :outcome_os_marriage_impossible_no_laos_locals,
-          :outcome_os_no_cni,
-          :outcome_os_oman,
-          :outcome_os_other_countries,
-          :outcome_os_poland,
-          :outcome_os_slovenia,
-          :outcome_portugal,
-          :outcome_spain,
-          :outcome_ss_affirmation,
-          :outcome_ss_marriage,
-          :outcome_ss_marriage_malta,
-          :outcome_ss_marriage_not_possible,
-          :outcome_switzerland
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.sex_of_your_partner = response
           if calculator.ceremony_country == 'brazil' && calculator.resident_outside_of_uk?
-            :outcome_brazil_not_living_in_the_uk
+            outcome :outcome_brazil_not_living_in_the_uk
           elsif calculator.ceremony_country == "netherlands"
-            :outcome_marriage_via_local_authorities
+            outcome :outcome_marriage_via_local_authorities
           elsif calculator.ceremony_country == "portugal"
-            :outcome_portugal
+            outcome :outcome_portugal
           elsif calculator.ceremony_country == "ireland"
-            :outcome_ireland
+            outcome :outcome_ireland
           elsif calculator.ceremony_country == "switzerland"
-            :outcome_switzerland
+            outcome :outcome_switzerland
           elsif calculator.ceremony_country == "spain"
-            :outcome_spain
+            outcome :outcome_spain
           elsif calculator.partner_is_opposite_sex?
             if calculator.ceremony_country == 'hong-kong'
-              :outcome_os_hong_kong
+              outcome :outcome_os_hong_kong
             elsif calculator.ceremony_country == 'germany'
-              :outcome_os_germany
+              outcome :outcome_os_germany
             elsif calculator.ceremony_country == 'oman'
-              :outcome_os_oman
+              outcome :outcome_os_oman
             elsif calculator.ceremony_country == 'belarus'
-              :outcome_os_belarus
+              outcome :outcome_os_belarus
             elsif calculator.ceremony_country == 'kuwait'
-              :outcome_os_kuwait
+              outcome :outcome_os_kuwait
             elsif calculator.ceremony_country == 'japan'
-              :outcome_os_japan
+              outcome :outcome_os_japan
             elsif calculator.resident_of_third_country? &&
                 (
                   calculator.opposite_sex_consular_cni_country? ||
                   %w(kosovo).include?(calculator.ceremony_country) ||
                   calculator.opposite_sex_consular_cni_in_nearby_country?
                 )
-              :outcome_consular_cni_os_residing_in_third_country
+              outcome :outcome_consular_cni_os_residing_in_third_country
             elsif calculator.ceremony_country == 'norway' && calculator.resident_of_third_country?
-              :outcome_consular_cni_os_residing_in_third_country
+              outcome :outcome_consular_cni_os_residing_in_third_country
             elsif calculator.ceremony_country == 'italy'
-              :outcome_os_italy
+              outcome :outcome_os_italy
             elsif calculator.ceremony_country == 'cambodia'
-              :outcome_os_cambodia
+              outcome :outcome_os_cambodia
             elsif calculator.ceremony_country == "colombia"
-              :outcome_os_colombia
+              outcome :outcome_os_colombia
             elsif calculator.ceremony_country == 'germany'
-              :outcome_os_germany
+              outcome :outcome_os_germany
             elsif calculator.ceremony_country == "kosovo"
-              :outcome_os_kosovo
+              outcome :outcome_os_kosovo
             elsif calculator.ceremony_country == "indonesia"
-              :outcome_os_indonesia
+              outcome :outcome_os_indonesia
             elsif calculator.ceremony_country == "laos" && calculator.partner_is_not_national_of_ceremony_country?
-              :outcome_os_marriage_impossible_no_laos_locals
+              outcome :outcome_os_marriage_impossible_no_laos_locals
             elsif calculator.ceremony_country == "laos"
-              :outcome_os_laos
+              outcome :outcome_os_laos
             elsif calculator.ceremony_country == 'poland'
-              :outcome_os_poland
+              outcome :outcome_os_poland
             elsif calculator.ceremony_country == 'slovenia'
-              :outcome_os_slovenia
+              outcome :outcome_os_slovenia
             elsif calculator.opposite_sex_consular_cni_country? ||
                 (
                   calculator.resident_of_uk? &&
                   calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country?
                 ) ||
                 calculator.opposite_sex_consular_cni_in_nearby_country?
-              :outcome_os_consular_cni
+              outcome :outcome_os_consular_cni
             elsif calculator.ceremony_country == "finland" && calculator.resident_of_uk?
-              :outcome_os_consular_cni
+              outcome :outcome_os_consular_cni
             elsif calculator.ceremony_country == "norway" && calculator.resident_of_uk?
-              :outcome_os_consular_cni
+              outcome :outcome_os_consular_cni
             elsif calculator.opposite_sex_affirmation_country?
-              :outcome_os_affirmation
+              outcome :outcome_os_affirmation
             elsif calculator.ceremony_country_in_the_commonwealth? ||
                 calculator.ceremony_country == 'zimbabwe'
-              :outcome_os_commonwealth
+              outcome :outcome_os_commonwealth
             elsif calculator.ceremony_country_is_british_overseas_territory?
-              :outcome_os_bot
+              outcome :outcome_os_bot
             elsif calculator.opposite_sex_no_consular_cni_country? ||
                 (
                   calculator.resident_outside_of_uk? &&
                   calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country?
                 )
-              :outcome_os_no_cni
+              outcome :outcome_os_no_cni
             elsif calculator.opposite_sex_marriage_via_local_authorities?
-              :outcome_marriage_via_local_authorities
+              outcome :outcome_marriage_via_local_authorities
             elsif calculator.opposite_sex_in_other_countries?
-              :outcome_os_other_countries
+              outcome :outcome_os_other_countries
             end
           elsif calculator.partner_is_same_sex?
             if %w(belgium norway).include?(calculator.ceremony_country)
-              :outcome_ss_affirmation
+              outcome :outcome_ss_affirmation
             elsif calculator.same_sex_ceremony_country_unknown_or_has_no_embassies?
-              :outcome_os_no_cni
+              outcome :outcome_os_no_cni
             elsif calculator.ceremony_country == "malta"
-              :outcome_ss_marriage_malta
+              outcome :outcome_ss_marriage_malta
             elsif calculator.same_sex_marriage_not_possible?
-              :outcome_ss_marriage_not_possible
+              outcome :outcome_ss_marriage_not_possible
             elsif calculator.ceremony_country == "germany" && calculator.partner_is_national_of_ceremony_country?
-              :outcome_cp_or_equivalent
+              outcome :outcome_cp_or_equivalent
             elsif calculator.same_sex_marriage_country? ||
                 (
                   calculator.same_sex_marriage_country_when_couple_british? &&
                   calculator.partner_british?
                 ) ||
                 calculator.same_sex_marriage_and_civil_partnership?
-              :outcome_ss_marriage
+              outcome :outcome_ss_marriage
             elsif calculator.civil_partnership_equivalent_country?
-              :outcome_cp_or_equivalent
+              outcome :outcome_cp_or_equivalent
             elsif calculator.civil_partnership_cni_not_required_country?
-              :outcome_cp_no_cni
+              outcome :outcome_cp_no_cni
             elsif %w(canada south-africa).include?(calculator.ceremony_country)
-              :outcome_cp_commonwealth_countries
+              outcome :outcome_cp_commonwealth_countries
             elsif calculator.civil_partnership_consular_country?
-              :outcome_cp_consular
+              outcome :outcome_cp_consular
             else
-              :outcome_cp_all_other_countries
+              outcome :outcome_cp_all_other_countries
             end
           end
         end
diff --git a/test/data/marriage-abroad-files.yml b/test/data/marriage-abroad-files.yml
index e151aa92475..bb4cbb14f84 100644
--- a/test/data/marriage-abroad-files.yml
+++ b/test/data/marriage-abroad-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/marriage-abroad.rb: 4bfc3759306b93273cd92f1c66a64d24
+lib/smart_answer_flows/marriage-abroad.rb: a5d0e498bc6d5f6a76b34da617537680
 test/data/marriage-abroad-questions-and-responses.yml: 87f39a00d77fe0566a79e5cddbca765e
 test/data/marriage-abroad-responses-and-expected-results.yml: c388fc820b41309bb7594e9ef908a70e
 lib/smart_answer_flows/marriage-abroad/marriage_abroad.govspeak.erb: b4d0cfc1c7c4776d968c9b5b6df85027

From b47307f009557df3361af222d9f6dea903a19419 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:43:21 +0100
Subject: [PATCH 19/44] Automatic next_node detection in
 maternity-paternity-calculator

---
 .../maternity-paternity-calculator.rb               | 13 ++++---------
 test/data/maternity-paternity-calculator-files.yml  |  2 +-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/smart_answer_flows/maternity-paternity-calculator.rb b/lib/smart_answer_flows/maternity-paternity-calculator.rb
index 5c2b30ef943..a02cba7922d 100644
--- a/lib/smart_answer_flows/maternity-paternity-calculator.rb
+++ b/lib/smart_answer_flows/maternity-paternity-calculator.rb
@@ -47,19 +47,14 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :baby_due_date_maternity?,
-          :leave_or_pay_for_adoption?,
-          :taking_paternity_leave_for_adoption?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'maternity'
-            :baby_due_date_maternity?
+            question :baby_due_date_maternity?
           when 'paternity'
-            :leave_or_pay_for_adoption?
+            question :leave_or_pay_for_adoption?
           when 'adoption'
-            :taking_paternity_leave_for_adoption?
+            question :taking_paternity_leave_for_adoption?
           end
         end
       end
diff --git a/test/data/maternity-paternity-calculator-files.yml b/test/data/maternity-paternity-calculator-files.yml
index ab80914e1b7..685b311857f 100644
--- a/test/data/maternity-paternity-calculator-files.yml
+++ b/test/data/maternity-paternity-calculator-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/maternity-paternity-calculator.rb: 0d35c271ee34e395afc1f71d649caf9e
+lib/smart_answer_flows/maternity-paternity-calculator.rb: 24795e82502be789510ddb1cb7f2632c
 test/data/maternity-paternity-calculator-questions-and-responses.yml: 1bf0c803cd8e8a091417b0e1e19d2bd2
 test/data/maternity-paternity-calculator-responses-and-expected-results.yml: a59f6821dd5b949861ab6261840e58e4
 lib/smart_answer_flows/maternity-paternity-calculator/maternity_paternity_calculator.govspeak.erb: c8c17c5f5e46a1b74cc8a6a2445486f7

From d125568c848b7a2b9d8e8944be5d21b4efa82fab Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:46:03 +0100
Subject: [PATCH 20/44] Automatic next_node detection in
 minimum-wage-calculator-employers

---
 .../minimum-wage-calculator-employers.rb      | 22 +++++--------------
 ...inimum-wage-calculator-employers-files.yml |  2 +-
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/smart_answer_flows/minimum-wage-calculator-employers.rb b/lib/smart_answer_flows/minimum-wage-calculator-employers.rb
index bc5ad68662a..fdca9cfe484 100644
--- a/lib/smart_answer_flows/minimum-wage-calculator-employers.rb
+++ b/lib/smart_answer_flows/minimum-wage-calculator-employers.rb
@@ -19,17 +19,12 @@ def define
           nil
         end
 
-        permitted_next_nodes = [
-          :are_you_an_apprentice?,
-          :past_payment_date?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'current_payment'
-            :are_you_an_apprentice?
+            question :are_you_an_apprentice?
           when 'past_payment'
-            :past_payment_date?
+            question :past_payment_date?
           end
         end
       end
@@ -44,17 +39,12 @@ def define
           calculator.valid_age?(response)
         end
 
-        permitted_next_nodes = [
-          :under_school_leaving_age,
-          :how_often_do_you_get_paid?
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.age = response
           if calculator.under_school_leaving_age?
-            :under_school_leaving_age
+            outcome :under_school_leaving_age
           else
-            :how_often_do_you_get_paid?
+            question :how_often_do_you_get_paid?
           end
         end
       end
diff --git a/test/data/minimum-wage-calculator-employers-files.yml b/test/data/minimum-wage-calculator-employers-files.yml
index 04950483e64..e8657813538 100644
--- a/test/data/minimum-wage-calculator-employers-files.yml
+++ b/test/data/minimum-wage-calculator-employers-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/minimum-wage-calculator-employers.rb: 1e9730889bb15889ee910a41ab98c404
+lib/smart_answer_flows/minimum-wage-calculator-employers.rb: ba33a2456bf45b416a6339a4f1385a23
 test/data/minimum-wage-calculator-employers-questions-and-responses.yml: ddadb3fc5fc1d82d77f53fbc90752d89
 test/data/minimum-wage-calculator-employers-responses-and-expected-results.yml: 3f047b0007e3432a77ea4e896ea763ea
 lib/smart_answer_flows/minimum-wage-calculator-employers/minimum_wage_calculator_employers.govspeak.erb: 925ea68bf1c68cb973393159b8ea01b7

From 1a931360382827c62f1df36de1dbd994ab1c2097 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:49:18 +0100
Subject: [PATCH 21/44] Automatic next_node detection in overseas-passports

---
 lib/smart_answer_flows/overseas-passports.rb | 39 ++++++--------------
 test/data/overseas-passports-files.yml       |  2 +-
 2 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/lib/smart_answer_flows/overseas-passports.rb b/lib/smart_answer_flows/overseas-passports.rb
index 5bf366ba64e..045ec90dbd2 100644
--- a/lib/smart_answer_flows/overseas-passports.rb
+++ b/lib/smart_answer_flows/overseas-passports.rb
@@ -41,21 +41,15 @@ def define
           %w(british-indian-ocean-territory north-korea south-georgia-and-south-sandwich-islands).include?(response)
         end
 
-        permitted_next_nodes = [
-          :cannot_apply,
-          :which_opt?,
-          :apply_in_neighbouring_country,
-          :renewing_replacing_applying?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if ineligible_country
-            :cannot_apply
+            outcome :cannot_apply
           elsif response == 'the-occupied-palestinian-territories'
-            :which_opt?
+            question :which_opt?
           elsif apply_in_neighbouring_countries
-            :apply_in_neighbouring_country
+            outcome :apply_in_neighbouring_country
           else
-            :renewing_replacing_applying?
+            question :renewing_replacing_applying?
           end
         end
       end
@@ -151,19 +145,14 @@ def define
 
         save_input_as :child_or_adult
 
-        permitted_next_nodes = [
-          :country_of_birth?,
-          :ips_application_result_online,
-          :ips_application_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if is_ips_application
             if %w(applying renewing_old).include?(application_action)
-              :country_of_birth?
+              question :country_of_birth?
             elsif ips_result_type == :ips_application_result_online
-              :ips_application_result_online
+              outcome :ips_application_result_online
             else
-              :ips_application_result
+              outcome :ips_application_result
             end
           end
         end
@@ -185,16 +174,12 @@ def define
           supporting_documents.split("_")[3]
         end
 
-        permitted_next_nodes = [
-          :ips_application_result_online,
-          :ips_application_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if is_ips_application
             if ips_result_type == :ips_application_result_online
-              :ips_application_result_online
+              outcome :ips_application_result_online
             else
-              :ips_application_result
+              outcome :ips_application_result
             end
           end
         end
diff --git a/test/data/overseas-passports-files.yml b/test/data/overseas-passports-files.yml
index 76e2f21beac..8a2b0721db9 100644
--- a/test/data/overseas-passports-files.yml
+++ b/test/data/overseas-passports-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/overseas-passports.rb: 6b4ae2e611660154032a4709fe077be0
+lib/smart_answer_flows/overseas-passports.rb: ca4a6d321ee16b4b8a0f55f72dda7425
 test/data/overseas-passports-questions-and-responses.yml: 4c6749fcf0a37deb135fc8c94fa52bc7
 test/data/overseas-passports-responses-and-expected-results.yml: aca0c7e72dfbf84606a47cb7d6d7f758
 lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb: 748ca30b4392d385f1546569cfc949fe

From c38c725ff02d1b2d239507fe5f086c5d0394a18d Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 11:56:04 +0100
Subject: [PATCH 22/44] Automatic next_node detection in
 part-year-profit-tax-credits

---
 .../part-year-profit-tax-credits.rb           | 60 +++++++------------
 1 file changed, 20 insertions(+), 40 deletions(-)

diff --git a/lib/smart_answer_flows/part-year-profit-tax-credits.rb b/lib/smart_answer_flows/part-year-profit-tax-credits.rb
index 2227794aa41..65580f19c45 100644
--- a/lib/smart_answer_flows/part-year-profit-tax-credits.rb
+++ b/lib/smart_answer_flows/part-year-profit-tax-credits.rb
@@ -15,20 +15,18 @@ def define
           Calculators::PartYearProfitTaxCreditsCalculator.new
         end
 
-        permitted_next_nodes = [:what_date_do_your_accounts_go_up_to?]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.tax_credits_award_ends_on = response
-          :what_date_do_your_accounts_go_up_to?
+          question :what_date_do_your_accounts_go_up_to?
         end
       end
 
       date_question :what_date_do_your_accounts_go_up_to? do
         default_year { 0 }
 
-        permitted_next_nodes = [:have_you_stopped_trading?]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.accounts_end_month_and_day = response
-          :have_you_stopped_trading?
+          question :have_you_stopped_trading?
         end
       end
 
@@ -36,17 +34,13 @@ def define
         option "yes"
         option "no"
 
-        permitted_next_nodes = [
-          :did_you_start_trading_before_the_relevant_accounting_year?,
-          :do_your_accounts_cover_a_12_month_period?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'yes'
             calculator.stopped_trading = true
-            :did_you_start_trading_before_the_relevant_accounting_year?
+            question :did_you_start_trading_before_the_relevant_accounting_year?
           elsif response == 'no'
             calculator.stopped_trading = false
-            :do_your_accounts_cover_a_12_month_period?
+            question :do_your_accounts_cover_a_12_month_period?
           end
         end
       end
@@ -57,15 +51,11 @@ def define
 
         precalculate(:accounting_year_begins_on) { calculator.accounting_year.begins_on }
 
-        permitted_next_nodes = [
-          :when_did_you_stop_trading?,
-          :when_did_you_start_trading?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == "yes"
-            :when_did_you_stop_trading?
+            question :when_did_you_stop_trading?
           elsif response == "no"
-            :when_did_you_start_trading?
+            question :when_did_you_start_trading?
           end
         end
       end
@@ -81,10 +71,9 @@ def define
           calculator.valid_stopped_trading_date?(response)
         end
 
-        permitted_next_nodes = [:what_is_your_taxable_profit?]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.stopped_trading_on = response
-          :what_is_your_taxable_profit?
+          question :what_is_your_taxable_profit?
         end
       end
 
@@ -94,15 +83,11 @@ def define
 
         precalculate(:accounting_year_ends_on) { calculator.accounting_year.ends_on }
 
-        permitted_next_nodes = [
-          :what_is_your_taxable_profit?,
-          :when_did_you_start_trading?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == "yes"
-            :what_is_your_taxable_profit?
+            question :what_is_your_taxable_profit?
           else
-            :when_did_you_start_trading?
+            question :when_did_you_start_trading?
           end
         end
       end
@@ -117,16 +102,12 @@ def define
           calculator.valid_start_trading_date?(response)
         end
 
-        permitted_next_nodes = [
-          :when_did_you_stop_trading?,
-          :what_is_your_taxable_profit?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.started_trading_on = response
           if calculator.stopped_trading
-            :when_did_you_stop_trading?
+            question :when_did_you_stop_trading?
           else
-            :what_is_your_taxable_profit?
+            question :what_is_your_taxable_profit?
           end
         end
       end
@@ -135,10 +116,9 @@ def define
         precalculate(:basis_period_begins_on) { calculator.basis_period.begins_on }
         precalculate(:basis_period_ends_on)   { calculator.basis_period.ends_on }
 
-        permitted_next_nodes = [:result]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.taxable_profit = response
-          :result
+          outcome :result
         end
       end
 

From 09331822015ac1310b32e532b3b03b546a52fc9c Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 12:47:16 +0100
Subject: [PATCH 23/44] Automatic next_node detection in pay-leave-for-parents

---
 .../pay-leave-for-parents.rb                  | 434 +++++++-----------
 test/data/pay-leave-for-parents-files.yml     |   2 +-
 2 files changed, 172 insertions(+), 264 deletions(-)

diff --git a/lib/smart_answer_flows/pay-leave-for-parents.rb b/lib/smart_answer_flows/pay-leave-for-parents.rb
index 0a1758b1f77..08ec8e4aa35 100644
--- a/lib/smart_answer_flows/pay-leave-for-parents.rb
+++ b/lib/smart_answer_flows/pay-leave-for-parents.rb
@@ -33,21 +33,16 @@ def define
 
         save_input_as :employment_status_of_mother
 
-        permitted_next_nodes = [
-          :mother_started_working_before_continuity_start_date,
-          :mother_worked_at_least_26_weeks,
-          :employment_status_of_partner
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if two_carers == 'no'
             case response
             when 'employee', 'worker'
-              :mother_started_working_before_continuity_start_date
+              question :mother_started_working_before_continuity_start_date
             when 'self-employed', 'unemployed'
-              :mother_worked_at_least_26_weeks
+              question :mother_worked_at_least_26_weeks
             end
           elsif two_carers == 'yes'
-            :employment_status_of_partner
+            question :employment_status_of_partner
           end
         end
       end
@@ -60,16 +55,12 @@ def define
 
         save_input_as :employment_status_of_partner
 
-        permitted_next_nodes = [
-          :mother_started_working_before_continuity_start_date,
-          :mother_worked_at_least_26_weeks
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case employment_status_of_mother
           when 'employee', 'worker'
-            :mother_started_working_before_continuity_start_date
+            question :mother_started_working_before_continuity_start_date
           when 'self-employed', 'unemployed'
-            :mother_worked_at_least_26_weeks
+            question :mother_worked_at_least_26_weeks
           end
         end
       end
@@ -122,39 +113,32 @@ def define
           calculator.lower_earnings_end_date(due_date)
         end
 
-        permitted_next_nodes = [
-          :outcome_mat_leave_mat_pay,
-          :outcome_mat_pay,
-          :partner_started_working_before_continuity_start_date,
-          :partner_worked_at_least_26_weeks,
-          :mother_worked_at_least_26_weeks
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(response)
             if two_carers == 'no'
               if employment_status_of_mother == 'employee'
-                :outcome_mat_leave_mat_pay
+                outcome :outcome_mat_leave_mat_pay
               elsif employment_status_of_mother == 'worker'
-                :outcome_mat_pay
+                outcome :outcome_mat_pay
               end
             elsif two_carers == 'yes'
               case employment_status_of_partner
               when 'employee', 'worker'
-                :partner_started_working_before_continuity_start_date
+                question :partner_started_working_before_continuity_start_date
               when 'self-employed', 'unemployed'
                 if due_date >= Date.parse('2015-04-05')
-                  :partner_worked_at_least_26_weeks
+                  question :partner_worked_at_least_26_weeks
                 elsif due_date < Date.parse('2015-04-05')
                   if employment_status_of_mother == 'employee'
-                    :outcome_mat_leave_mat_pay
+                    outcome :outcome_mat_leave_mat_pay
                   elsif employment_status_of_mother == 'worker'
-                    :outcome_mat_pay
+                    outcome :outcome_mat_pay
                   end
                 end
               end
             end
           else
-            :mother_worked_at_least_26_weeks
+            question :mother_worked_at_least_26_weeks
           end
         end
       end
@@ -190,49 +174,40 @@ def define
           calculator.earnings_employment_end_date(due_date)
         end
 
-        permitted_next_nodes = [
-          :salary_1_66_weeks,
-          :outcome_mat_leave,
-          :outcome_single_birth_nothing,
-          :partner_started_working_before_continuity_start_date,
-          :partner_worked_at_least_26_weeks,
-          :outcome_mat_allowance_14_weeks,
-          :outcome_birth_nothing
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if two_carers == 'no'
             if calculator.earnings_employment(response, mother_worked_at_least_26_weeks)
-              :salary_1_66_weeks
+              question :salary_1_66_weeks
             elsif employment_status_of_mother == 'employee'
               if mother_still_working_on_continuity_end_date == 'yes'
-                :outcome_mat_leave
+                outcome :outcome_mat_leave
               elsif mother_still_working_on_continuity_end_date == 'no'
-                :outcome_single_birth_nothing
+                outcome :outcome_single_birth_nothing
               end
             elsif %w(worker self-employed unemployed).include?(employment_status_of_mother)
-              :outcome_single_birth_nothing
+              outcome :outcome_single_birth_nothing
             end
           elsif two_carers == 'yes'
             if calculator.earnings_employment(response, mother_worked_at_least_26_weeks)
-              :salary_1_66_weeks
+              question :salary_1_66_weeks
             elsif %w(employee worker).include?(employment_status_of_partner)
-              :partner_started_working_before_continuity_start_date
+              question :partner_started_working_before_continuity_start_date
             elsif %w(self-employed unemployed).include?(employment_status_of_partner)
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && due_date >= Date.parse('2015-04-05')
-                  :partner_worked_at_least_26_weeks
+                  question :partner_worked_at_least_26_weeks
                 elsif mother_still_working_on_continuity_end_date == 'yes'
-                  :outcome_mat_leave
+                  outcome :outcome_mat_leave
                 elsif mother_still_working_on_continuity_end_date == 'no'
-                  :outcome_birth_nothing
+                  outcome :outcome_birth_nothing
                 end
               elsif %w(worker self-employed).include?(employment_status_of_mother)
-                :outcome_birth_nothing
+                outcome :outcome_birth_nothing
               elsif employment_status_of_mother == 'unemployed'
                 if employment_status_of_partner == 'self-employed'
-                  :outcome_mat_allowance_14_weeks
+                  outcome :outcome_mat_allowance_14_weeks
                 elsif employment_status_of_partner == 'unemployed'
-                  :outcome_birth_nothing
+                  outcome :outcome_birth_nothing
                 end
               end
             end
@@ -251,37 +226,31 @@ def define
           calculator.earnings_employment_end_date(due_date)
         end
 
-        permitted_next_nodes = [
-          :outcome_mat_allowance_mat_leave,
-          :outcome_mat_allowance,
-          :partner_started_working_before_continuity_start_date,
-          :partner_worked_at_least_26_weeks
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if two_carers == 'no'
             if employment_status_of_mother == 'employee'
               if mother_still_working_on_continuity_end_date == 'yes'
-                :outcome_mat_allowance_mat_leave
+                outcome :outcome_mat_allowance_mat_leave
               elsif mother_still_working_on_continuity_end_date == 'no'
-                :outcome_mat_allowance
+                outcome :outcome_mat_allowance
               end
             elsif %w(worker self-employed unemployed).include?(employment_status_of_mother)
-              :outcome_mat_allowance
+              outcome :outcome_mat_allowance
             end
           elsif two_carers == 'yes'
             if %w(employee worker).include?(employment_status_of_partner)
-              :partner_started_working_before_continuity_start_date
+              question :partner_started_working_before_continuity_start_date
             elsif %w(self-employed unemployed).include?(employment_status_of_partner)
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && due_date >= Date.parse('2015-04-05')
-                  :partner_worked_at_least_26_weeks
+                  question :partner_worked_at_least_26_weeks
                 elsif mother_still_working_on_continuity_end_date == 'yes'
-                  :outcome_mat_allowance_mat_leave
+                  outcome :outcome_mat_allowance_mat_leave
                 elsif mother_still_working_on_continuity_end_date == 'no'
-                  :outcome_mat_allowance
+                  outcome :outcome_mat_allowance
                 end
               elsif %w(worker self-employed unemployed).include?(employment_status_of_mother)
-                :outcome_mat_allowance
+                outcome :outcome_mat_allowance
               end
             end
           end
@@ -338,132 +307,89 @@ def define
           calculator.lower_earnings_end_date(due_date)
         end
 
-        permitted_next_nodes = [
-          :outcome_birth_nothing,
-          :outcome_mat_allowance,
-          :outcome_mat_allowance_mat_leave,
-          :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave,
-          :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay,
-          :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_both_shared_leave_pat_shared_pay,
-          :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay,
-          :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave,
-          :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay,
-          :outcome_mat_allowance_mat_leave_pat_pay_mat_shared_leave_pat_shared_pay,
-          :outcome_mat_allowance_mat_leave_pat_pay_pat_shared_pay,
-          :outcome_mat_allowance_pat_leave_additional_pat_leave,
-          :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay,
-          :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay,
-          :outcome_mat_allowance_pat_leave_pat_shared_leave,
-          :outcome_mat_allowance_pat_pay_additional_pat_pay,
-          :outcome_mat_allowance_pat_pay_pat_shared_pay,
-          :outcome_mat_leave,
-          :outcome_mat_leave_mat_pay,
-          :outcome_mat_leave_mat_pay_pat_leave_additional_pat_leave,
-          :outcome_mat_leave_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay,
-          :outcome_mat_leave_mat_pay_pat_leave_pat_pay_both_shared_leave_both_shared_pay,
-          :outcome_mat_leave_mat_pay_pat_pay_additional_pat_pay,
-          :outcome_mat_leave_mat_pay_pat_pay_mat_shared_leave_both_shared_pay,
-          :outcome_mat_leave_pat_leave,
-          :outcome_mat_leave_pat_leave_additional_pat_leave,
-          :outcome_mat_leave_pat_leave_pat_pay,
-          :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave,
-          :outcome_mat_leave_pat_leave_pat_pay_mat_shared_leave,
-          :outcome_mat_leave_pat_pay,
-          :outcome_mat_leave_pat_pay_mat_shared_leave,
-          :outcome_mat_pay,
-          :outcome_mat_pay_pat_leave_additional_pat_leave,
-          :outcome_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay,
-          :outcome_mat_pay_pat_leave_pat_pay_pat_shared_leave_both_shared_pay,
-          :outcome_mat_pay_pat_pay_additional_pat_pay,
-          :outcome_mat_pay_pat_pay_both_shared_pay,
-          :outcome_pat_leave,
-          :outcome_pat_leave_pat_pay,
-          :outcome_pat_pay,
-          :partner_worked_at_least_26_weeks
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if employment_status_of_partner == 'employee'
             if calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date) && calculator.lower_earnings(response)
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay_pat_leave_pat_pay_both_shared_leave_both_shared_pay
+                    outcome :outcome_mat_leave_mat_pay_pat_leave_pat_pay_both_shared_leave_both_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                    outcome :outcome_mat_leave_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                   end
                 elsif mother_started_working_before_continuity_start_date == 'yes' && mother_still_working_on_continuity_end_date == 'yes'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_both_shared_leave_pat_shared_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_both_shared_leave_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_pat_pay_mat_shared_leave
+                      outcome :outcome_mat_leave_pat_leave_pat_pay_mat_shared_leave
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
+                      outcome :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'yes'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_pat_pay
+                      outcome :outcome_mat_leave_pat_leave_pat_pay
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
+                      outcome :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'no'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+                      outcome :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_leave_pat_pay
+                      outcome :outcome_pat_leave_pat_pay
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                      outcome :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_leave_pat_pay
+                      outcome :outcome_pat_leave_pat_pay
                     end
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_leave_pat_pay_pat_shared_leave_both_shared_pay
+                    outcome :outcome_mat_pay_pat_leave_pat_pay_pat_shared_leave_both_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                    outcome :outcome_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+                      outcome :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_leave_pat_pay
+                      outcome :outcome_pat_leave_pat_pay
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                      outcome :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_leave_pat_pay
+                      outcome :outcome_pat_leave_pat_pay
                     end
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_pat_leave_pat_pay
+                  outcome :outcome_pat_leave_pat_pay
                 elsif calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
+                    outcome :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
+                    outcome :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
                   end
                 end
               end
@@ -471,72 +397,72 @@ def define
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay_pat_leave_additional_pat_leave
+                    outcome :outcome_mat_leave_mat_pay_pat_leave_additional_pat_leave
                   end
                 elsif calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_leave_pat_leave_additional_pat_leave
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'yes'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave
+                      outcome :outcome_mat_leave_pat_leave
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_leave_pat_leave_additional_pat_leave
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'no'
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
                     if due_date >= Date.parse('2015-04-05')
-                      :outcome_mat_allowance_pat_leave_pat_shared_leave
+                      outcome :outcome_mat_allowance_pat_leave_pat_shared_leave
                     elsif due_date < Date.parse('2015-04-05')
-                      :outcome_mat_allowance_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_allowance_pat_leave_additional_pat_leave
                     end
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_pat_leave
+                    outcome :outcome_pat_leave
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_leave_additional_pat_leave
+                    outcome :outcome_mat_pay_pat_leave_additional_pat_leave
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
                     if due_date >= Date.parse('2015-04-05')
-                      :outcome_mat_allowance_pat_leave_pat_shared_leave
+                      outcome :outcome_mat_allowance_pat_leave_pat_shared_leave
                     elsif due_date < Date.parse('2015-04-05')
-                      :outcome_mat_allowance_pat_leave_additional_pat_leave
+                      outcome :outcome_mat_allowance_pat_leave_additional_pat_leave
                     end
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_pat_leave
+                    outcome :outcome_pat_leave
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_leave_pat_shared_leave
+                    outcome :outcome_mat_allowance_pat_leave_pat_shared_leave
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_leave_additional_pat_leave
+                    outcome :outcome_mat_allowance_pat_leave_additional_pat_leave
                   end
                 elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_pat_leave
+                  outcome :outcome_pat_leave
                 end
               end
             elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
@@ -544,51 +470,51 @@ def define
                 if mother_still_working_on_continuity_end_date == 'yes'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
-                      :partner_worked_at_least_26_weeks
+                      question :partner_worked_at_least_26_weeks
                     else
                       if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_allowance_mat_leave
+                        outcome :outcome_mat_allowance_mat_leave
                       elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_leave
+                        outcome :outcome_mat_leave
                       end
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
-                      :outcome_mat_leave_mat_pay
+                      outcome :outcome_mat_leave_mat_pay
                     elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                       if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_allowance_mat_leave
+                        outcome :outcome_mat_allowance_mat_leave
                       elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_leave
+                        outcome :outcome_mat_leave
                       end
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'no'
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance
+                    outcome :outcome_mat_allowance
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_birth_nothing
+                    outcome :outcome_birth_nothing
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay
+                    outcome :outcome_mat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance
+                    outcome :outcome_mat_allowance
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_birth_nothing
+                    outcome :outcome_birth_nothing
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_mat_allowance
+                  outcome :outcome_mat_allowance
                 elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_birth_nothing
+                  outcome :outcome_birth_nothing
                 end
               end
             end
@@ -597,75 +523,75 @@ def define
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay_pat_pay_mat_shared_leave_both_shared_pay
+                    outcome :outcome_mat_leave_mat_pay_pat_pay_mat_shared_leave_both_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_leave_mat_pay_pat_pay_additional_pat_pay
                   end
                 elsif calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_pay_mat_shared_leave_pat_shared_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_pay_mat_shared_leave_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_pay_mat_shared_leave
+                      outcome :outcome_mat_leave_pat_pay_mat_shared_leave
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
+                      outcome :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_pay
+                      outcome :outcome_mat_leave_pat_pay
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'yes'
                   if !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_leave_pat_pay
+                    outcome :outcome_mat_leave_pat_pay
                   elsif due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_allowance_mat_leave_pat_pay_pat_shared_pay
+                    outcome :outcome_mat_allowance_mat_leave_pat_pay_pat_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
                   end
                 elsif mother_still_working_on_continuity_end_date == 'no'
                   if !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_pat_pay
+                    outcome :outcome_pat_pay
                   elsif due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_pay_pat_shared_pay
+                    outcome :outcome_mat_allowance_pat_pay_pat_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_allowance_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_allowance_pat_pay_additional_pat_pay
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_pay_both_shared_pay
+                    outcome :outcome_mat_pay_pat_pay_both_shared_pay
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_pay_pat_pay_additional_pat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_pay_pat_shared_pay
+                      outcome :outcome_mat_allowance_pat_pay_pat_shared_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_pay
+                      outcome :outcome_pat_pay
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_pat_pay_additional_pat_pay
+                      outcome :outcome_mat_allowance_pat_pay_additional_pat_pay
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_pat_pay
+                      outcome :outcome_pat_pay
                     end
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if due_date >= Date.parse('2015-04-05')
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance_pat_pay_pat_shared_pay
+                    outcome :outcome_mat_allowance_pat_pay_pat_shared_pay
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_pat_pay
+                    outcome :outcome_pat_pay
                   end
                 elsif due_date < Date.parse('2015-04-05')
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_allowance_pat_pay_additional_pat_pay
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_pat_pay
+                    outcome :outcome_pat_pay
                   end
                 end
               end
@@ -673,52 +599,52 @@ def define
               if employment_status_of_mother == 'employee'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_leave_mat_pay
+                    outcome :outcome_mat_leave_mat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
                     if due_date >= Date.parse('2015-04-05')
-                      :partner_worked_at_least_26_weeks
+                      question :partner_worked_at_least_26_weeks
                     elsif due_date < Date.parse('2015-04-05') && calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave
+                      outcome :outcome_mat_allowance_mat_leave
                     elsif due_date < Date.parse('2015-04-05') && !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave
+                      outcome :outcome_mat_leave
                     end
                   elsif mother_still_working_on_continuity_end_date == 'yes'
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave
+                      outcome :outcome_mat_allowance_mat_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave
+                      outcome :outcome_mat_leave
                     end
                   elsif mother_still_working_on_continuity_end_date == 'no'
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance
+                      outcome :outcome_mat_allowance
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_birth_nothing
+                      outcome :outcome_birth_nothing
                     end
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay_pat_pay_additional_pat_pay
+                    outcome :outcome_mat_pay_pat_pay_additional_pat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance
+                    outcome :outcome_mat_allowance
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_birth_nothing
+                    outcome :outcome_birth_nothing
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_mat_allowance
+                  outcome :outcome_mat_allowance
                 elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_birth_nothing
+                  outcome :outcome_birth_nothing
                 end
               end
             elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
@@ -726,51 +652,51 @@ def define
                 if mother_still_working_on_continuity_end_date == 'yes'
                   if due_date >= Date.parse('2015-04-05')
                     if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
-                      :partner_worked_at_least_26_weeks
+                      question :partner_worked_at_least_26_weeks
                     elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date)
                       if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_allowance_mat_leave
+                        outcome :outcome_mat_allowance_mat_leave
                       elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_leave
+                        outcome :outcome_mat_leave
                       end
                     end
                   elsif due_date < Date.parse('2015-04-05')
                     if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
-                      :outcome_mat_leave_mat_pay
+                      outcome :outcome_mat_leave_mat_pay
                     elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                       if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_allowance_mat_leave
+                        outcome :outcome_mat_allowance_mat_leave
                       elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                        :outcome_mat_leave
+                        outcome :outcome_mat_leave
                       end
                     end
                   end
                 elsif mother_still_working_on_continuity_end_date == 'no'
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance
+                    outcome :outcome_mat_allowance
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_birth_nothing
+                    outcome :outcome_birth_nothing
                   end
                 end
               elsif employment_status_of_mother == 'worker'
                 if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if due_date >= Date.parse('2015-04-05')
-                    :partner_worked_at_least_26_weeks
+                    question :partner_worked_at_least_26_weeks
                   elsif due_date < Date.parse('2015-04-05')
-                    :outcome_mat_pay
+                    outcome :outcome_mat_pay
                   end
                 elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance
+                    outcome :outcome_mat_allowance
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_birth_nothing
+                    outcome :outcome_birth_nothing
                   end
                 end
               elsif %w(unemployed self-employed).include?(employment_status_of_mother)
                 if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_mat_allowance
+                  outcome :outcome_mat_allowance
                 elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                  :outcome_birth_nothing
+                  outcome :outcome_birth_nothing
                 end
               end
             end
@@ -809,46 +735,28 @@ def define
           calculator.earnings_employment_end_date(due_date)
         end
 
-        permitted_next_nodes = [
-          :outcome_mat_allowance_mat_leave,
-          :outcome_mat_allowance_mat_leave_mat_shared_leave,
-          :outcome_mat_allowance_mat_leave_pat_leave_both_shared_leave,
-          :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave,
-          :outcome_mat_leave,
-          :outcome_mat_leave_mat_pay,
-          :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay,
-          :outcome_mat_leave_mat_pay_pat_leave_both_shared_leave_mat_shared_pay,
-          :outcome_mat_leave_mat_pay_pat_leave_pat_shared_leave,
-          :outcome_mat_leave_mat_shared_leave,
-          :outcome_mat_leave_pat_leave,
-          :outcome_mat_leave_pat_leave_mat_shared_leave,
-          :outcome_mat_pay,
-          :outcome_mat_pay_mat_shared_pay,
-          :outcome_mat_pay_pat_leave,
-          :outcome_mat_pay_pat_leave_pat_shared_leave_mat_shared_pay
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if employment_status_of_mother == 'employee'
             if calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) && calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
               if employment_status_of_partner == 'employee'
                 if calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                   if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                    :outcome_mat_leave_mat_pay_pat_leave_both_shared_leave_mat_shared_pay
+                    outcome :outcome_mat_leave_mat_pay_pat_leave_both_shared_leave_mat_shared_pay
                   elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                    :outcome_mat_leave_mat_pay_pat_leave_pat_shared_leave
+                    outcome :outcome_mat_leave_mat_pay_pat_leave_pat_shared_leave
                   end
                 elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                   if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                    :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
+                    outcome :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
                   elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                    :outcome_mat_leave_mat_pay
+                    outcome :outcome_mat_leave_mat_pay
                   end
                 end
               elsif %w(worker self-employed unemployed).include?(employment_status_of_partner)
                 if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
+                  outcome :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
                 elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_leave_mat_pay
+                  outcome :outcome_mat_leave_mat_pay
                 end
               end
             elsif !calculator.continuity(mother_started_working_before_continuity_start_date, mother_still_working_on_continuity_end_date) || !calculator.lower_earnings(mother_earned_more_than_lower_earnings_limit)
@@ -856,44 +764,44 @@ def define
                 if employment_status_of_partner == 'employee'
                   if calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_both_shared_leave
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_both_shared_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave_mat_shared_leave
+                      outcome :outcome_mat_leave_pat_leave_mat_shared_leave
                     end
                   elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_mat_shared_leave
+                      outcome :outcome_mat_allowance_mat_leave_mat_shared_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_mat_shared_leave
+                      outcome :outcome_mat_leave_mat_shared_leave
                     end
                   end
                 elsif %w(worker self-employed unemployed).include?(employment_status_of_partner)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance_mat_leave_mat_shared_leave
+                    outcome :outcome_mat_allowance_mat_leave_mat_shared_leave
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_leave_mat_shared_leave
+                    outcome :outcome_mat_leave_mat_shared_leave
                   end
                 end
               elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
                 if employment_status_of_partner == 'employee'
                   if calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
+                      outcome :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave_pat_leave
+                      outcome :outcome_mat_leave_pat_leave
                     end
                   elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                     if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_allowance_mat_leave
+                      outcome :outcome_mat_allowance_mat_leave
                     elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                      :outcome_mat_leave
+                      outcome :outcome_mat_leave
                     end
                   end
                 elsif %w(worker self-employed unemployed).include?(employment_status_of_partner)
                   if calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_allowance_mat_leave
+                    outcome :outcome_mat_allowance_mat_leave
                   elsif !calculator.earnings_employment(mother_earned_at_least_390, mother_worked_at_least_26_weeks)
-                    :outcome_mat_leave
+                    outcome :outcome_mat_leave
                   end
                 end
               end
@@ -902,22 +810,22 @@ def define
             if employment_status_of_partner == 'employee'
               if calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                 if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_pay_pat_leave_pat_shared_leave_mat_shared_pay
+                  outcome :outcome_mat_pay_pat_leave_pat_shared_leave_mat_shared_pay
                 elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_pay_pat_leave
+                  outcome :outcome_mat_pay_pat_leave
                 end
               elsif !calculator.continuity(partner_started_working_before_continuity_start_date, partner_still_working_on_continuity_end_date)
                 if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_pay_mat_shared_pay
+                  outcome :outcome_mat_pay_mat_shared_pay
                 elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                  :outcome_mat_pay
+                  outcome :outcome_mat_pay
                 end
               end
             elsif %w(worker self-employed unemployed).include?(employment_status_of_partner)
               if calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                :outcome_mat_pay_mat_shared_pay
+                outcome :outcome_mat_pay_mat_shared_pay
               elsif !calculator.earnings_employment(response, partner_worked_at_least_26_weeks)
-                :outcome_mat_pay
+                outcome :outcome_mat_pay
               end
             end
           end
diff --git a/test/data/pay-leave-for-parents-files.yml b/test/data/pay-leave-for-parents-files.yml
index c2b5a24d979..80a23121461 100644
--- a/test/data/pay-leave-for-parents-files.yml
+++ b/test/data/pay-leave-for-parents-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/pay-leave-for-parents.rb: 30c6bb47eebae4f5a3130103c45534b4
+lib/smart_answer_flows/pay-leave-for-parents.rb: dfdc17ccda7e7e24f7443d83bb889337
 test/data/pay-leave-for-parents-questions-and-responses.yml: 6aae67d1b585e8445878fb2994bac8d1
 test/data/pay-leave-for-parents-responses-and-expected-results.yml: 2cdd65aad00267bdf9a534e22858f03d
 lib/smart_answer_flows/pay-leave-for-parents/outcomes/_additional_pat_leave.govspeak.erb: dcede84d936f876a3c91c1457c3afc01

From 8cb351884d40c110ae90cf130a2a829815aa06ca Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 12:50:19 +0100
Subject: [PATCH 24/44] Automatic next_node detection in pip-checker

---
 lib/smart_answer_flows/pip-checker.rb | 22 +++++++---------------
 test/data/pip-checker-files.yml       |  2 +-
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/lib/smart_answer_flows/pip-checker.rb b/lib/smart_answer_flows/pip-checker.rb
index 09bdd5bed84..72d01797bfe 100644
--- a/lib/smart_answer_flows/pip-checker.rb
+++ b/lib/smart_answer_flows/pip-checker.rb
@@ -27,31 +27,23 @@ def define
       date_question :what_is_your_dob? do
         date_of_birth_defaults
 
-        permitted_next_nodes = [
-          :result_1,
-          :result_2,
-          :result_3,
-          :result_5,
-          :result_6,
-          :result_7
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.dob = response
           if getting_dla
             if calculator.in_group_65?
-              :result_6
+              outcome :result_6
             elsif calculator.turning_16_before_oct_2013? || calculator.in_middle_group?
-              :result_7
+              outcome :result_7
             else
-              :result_5
+              outcome :result_5
             end
           else
             if calculator.is_65_or_over?
-              :result_2
+              outcome :result_2
             elsif calculator.is_16_to_64?
-              :result_3
+              outcome :result_3
             else
-              :result_1
+              outcome :result_1
             end
           end
         end
diff --git a/test/data/pip-checker-files.yml b/test/data/pip-checker-files.yml
index 77ff04f4420..e00824b19c0 100644
--- a/test/data/pip-checker-files.yml
+++ b/test/data/pip-checker-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/pip-checker.rb: bcba0a60b1f8117feac575868214f7a0
+lib/smart_answer_flows/pip-checker.rb: ba475a4f3d956416355d3c3068ecca0e
 test/data/pip-checker-questions-and-responses.yml: a4ce5f8dc606f2676c56f10409e3685b
 test/data/pip-checker-responses-and-expected-results.yml: a2c772b69a493d1844cfa32681057796
 lib/smart_answer_flows/pip-checker/outcomes/_scheme_postcodes.govspeak.erb: c8c884fbd4111d7cc3b015cb2be57b5a

From 85a88f6f48acf570c76174b1be036bdee6de9d98 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 12:55:41 +0100
Subject: [PATCH 25/44] Automatic next_node detection in register-a-birth

---
 lib/smart_answer_flows/register-a-birth.rb | 69 +++++++---------------
 test/data/register-a-birth-files.yml       |  2 +-
 2 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/lib/smart_answer_flows/register-a-birth.rb b/lib/smart_answer_flows/register-a-birth.rb
index 9c9fb48b813..2b97a4e092c 100644
--- a/lib/smart_answer_flows/register-a-birth.rb
+++ b/lib/smart_answer_flows/register-a-birth.rb
@@ -31,18 +31,13 @@ def define
           Calculators::RegistrationsDataQuery::COMMONWEALTH_COUNTRIES.include?(response)
         end
 
-        permitted_next_nodes = [
-          :commonwealth_result,
-          :no_embassy_result,
-          :who_has_british_nationality?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if country_has_no_embassy
-            :no_embassy_result
+            outcome :no_embassy_result
           elsif responded_with_commonwealth_country
-            :commonwealth_result
+            outcome :commonwealth_result
           else
-            :who_has_british_nationality?
+            question :who_has_british_nationality?
           end
         end
       end
@@ -56,16 +51,12 @@ def define
 
         save_input_as :british_national_parent
 
-        permitted_next_nodes = [
-          :married_couple_or_civil_partnership?,
-          :no_registration_result
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'mother', 'father', 'mother_and_father'
-            :married_couple_or_civil_partnership?
+            question :married_couple_or_civil_partnership?
           when 'neither'
-            :no_registration_result
+            outcome :no_registration_result
           end
         end
       end
@@ -79,15 +70,11 @@ def define
           response == 'no'
         end
 
-        permitted_next_nodes = [
-          :childs_date_of_birth?,
-          :where_are_you_now?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'no' && british_national_parent == 'father'
-            :childs_date_of_birth?
+            question :childs_date_of_birth?
           else
-            :where_are_you_now?
+            question :where_are_you_now?
           end
         end
       end
@@ -101,15 +88,11 @@ def define
           Date.new(2006, 07, 01) > response
         end
 
-        permitted_next_nodes = [
-          :homeoffice_result,
-          :where_are_you_now?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if before_july_2006
-            :homeoffice_result
+            outcome :homeoffice_result
           else
-            :where_are_you_now?
+            question :where_are_you_now?
           end
         end
       end
@@ -140,21 +123,15 @@ def define
           country_of_birth == 'north-korea'
         }
 
-        permitted_next_nodes = [
-          :no_birth_certificate_result,
-          :north_korea_result,
-          :oru_result,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if no_birth_certificate_exception
-            :no_birth_certificate_result
+            outcome :no_birth_certificate_result
           elsif response == 'another_country'
-            :which_country?
+            question :which_country?
           elsif response == 'same_country' && born_in_north_korea
-            :north_korea_result
+            outcome :north_korea_result
           else
-            :oru_result
+            outcome :oru_result
           end
         end
       end
@@ -173,15 +150,11 @@ def define
           response == 'north-korea'
         }
 
-        permitted_next_nodes = [
-          :north_korea_result,
-          :oru_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if currently_in_north_korea
-            :north_korea_result
+            outcome :north_korea_result
           else
-            :oru_result
+            outcome :oru_result
           end
         end
       end
diff --git a/test/data/register-a-birth-files.yml b/test/data/register-a-birth-files.yml
index c790870a2a4..bcd10764f43 100644
--- a/test/data/register-a-birth-files.yml
+++ b/test/data/register-a-birth-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/register-a-birth.rb: 730dba55e2cc3353cf3982277702d68c
+lib/smart_answer_flows/register-a-birth.rb: 2547ab0173817543d57d28959d996917
 test/data/register-a-birth-questions-and-responses.yml: c59cb1d0c11f3ad29f905b632f7c58bb
 test/data/register-a-birth-responses-and-expected-results.yml: 3ac4372034c86d8cc87665db59ff11d5
 lib/smart_answer_flows/register-a-birth/outcomes/commonwealth_result.govspeak.erb: a7c70e3191f23f7e747cb45587e4825f

From 61ae9e955e97a7821c9c8e3a5648ba7d8aa2786d Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 12:59:35 +0100
Subject: [PATCH 26/44] Automatic next_node detection in register-a-death

---
 lib/smart_answer_flows/register-a-death.rb | 46 +++++++---------------
 test/data/register-a-death-files.yml       |  2 +-
 2 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/lib/smart_answer_flows/register-a-death.rb b/lib/smart_answer_flows/register-a-death.rb
index f58fa14ef49..17b560151e7 100644
--- a/lib/smart_answer_flows/register-a-death.rb
+++ b/lib/smart_answer_flows/register-a-death.rb
@@ -19,16 +19,12 @@ def define
         option :northern_ireland
         option :overseas
 
-        permitted_next_nodes = [
-          :did_the_person_die_at_home_hospital?,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'england_wales', 'scotland', 'northern_ireland'
-            :did_the_person_die_at_home_hospital?
+            question :did_the_person_die_at_home_hospital?
           when 'overseas'
-            :which_country?
+            question :which_country?
           end
         end
       end
@@ -79,18 +75,13 @@ def define
           Calculators::RegistrationsDataQuery::COMMONWEALTH_COUNTRIES.include?(response)
         end
 
-        permitted_next_nodes = [
-          :commonwealth_result,
-          :no_embassy_result,
-          :where_are_you_now?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if responded_with_commonwealth_country
-            :commonwealth_result
+            outcome :commonwealth_result
           elsif country_has_no_embassy
-            :no_embassy_result
+            outcome :no_embassy_result
           else
-            :where_are_you_now?
+            question :where_are_you_now?
           end
         end
       end
@@ -113,18 +104,13 @@ def define
           country_of_death == 'north-korea'
         }
 
-        permitted_next_nodes = [
-          :north_korea_result,
-          :oru_result,
-          :which_country_are_you_in_now?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'same_country' && died_in_north_korea
-            :north_korea_result
+            outcome :north_korea_result
           elsif response == 'another_country'
-            :which_country_are_you_in_now?
+            question :which_country_are_you_in_now?
           else
-            :oru_result
+            outcome :oru_result
           end
         end
       end
@@ -143,15 +129,11 @@ def define
           response == 'north-korea'
         }
 
-        permitted_next_nodes = [
-          :north_korea_result,
-          :oru_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if currently_in_north_korea
-            :north_korea_result
+            outcome :north_korea_result
           else
-            :oru_result
+            outcome :oru_result
           end
         end
       end
diff --git a/test/data/register-a-death-files.yml b/test/data/register-a-death-files.yml
index 8e358441d85..2657fc7448f 100644
--- a/test/data/register-a-death-files.yml
+++ b/test/data/register-a-death-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/register-a-death.rb: 378f810da11670f93cadef74954fe302
+lib/smart_answer_flows/register-a-death.rb: b14cff3939ff97e557f0332e05127c4e
 test/data/register-a-death-questions-and-responses.yml: bae21b0a8be1bbaa2dd6febd505382d6
 test/data/register-a-death-responses-and-expected-results.yml: a69c595900ab2d85208c0ac92f186ae8
 lib/smart_answer_flows/register-a-death/outcomes/_footnote_oru_variants.govspeak.erb: 30e012cdde5aa7f4de5856a5db47a54c

From 98c62998190c5ec03db0b4317c870853138bba2e Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:01:49 +0100
Subject: [PATCH 27/44] Automatic next_node detection in
 report-a-lost-or-stolen-passport

---
 .../report-a-lost-or-stolen-passport.rb       | 20 ++++++-------------
 ...report-a-lost-or-stolen-passport-files.yml |  2 +-
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb b/lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb
index 28d7a21f77f..bbe6518c375 100644
--- a/lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb
+++ b/lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb
@@ -14,16 +14,12 @@ def define
 
         save_input_as :location
 
-        permitted_next_nodes = [
-          :complete_LS01_form,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'in_the_uk'
-            :complete_LS01_form
+            outcome :complete_LS01_form
           when 'abroad'
-            :which_country?
+            question :which_country?
           end
         end
       end
@@ -42,15 +38,11 @@ def define
 
         end
 
-        permitted_next_nodes = [
-          :contact_the_embassy,
-          :contact_the_embassy_canada
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'canada'
-            :contact_the_embassy_canada
+            outcome :contact_the_embassy_canada
           else
-            :contact_the_embassy
+            outcome :contact_the_embassy
           end
         end
       end
diff --git a/test/data/report-a-lost-or-stolen-passport-files.yml b/test/data/report-a-lost-or-stolen-passport-files.yml
index 343c55223a9..e2f8f31ec53 100644
--- a/test/data/report-a-lost-or-stolen-passport-files.yml
+++ b/test/data/report-a-lost-or-stolen-passport-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb: 55d1d72e3aa14151bd575a5e6fe46efd
+lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb: 376e81da9872bab11c9279ffc20186dc
 test/data/report-a-lost-or-stolen-passport-questions-and-responses.yml: 307a097c6429f895390b742dda8c9bc8
 test/data/report-a-lost-or-stolen-passport-responses-and-expected-results.yml: 7a5cb860803f433fa2416b7fcaf12f12
 lib/smart_answer_flows/report-a-lost-or-stolen-passport/outcomes/complete_LS01_form.govspeak.erb: 558860c7ddf7b7612af2bf793767f7dc

From 943fdd3b5420d44d049dd30d24b2a7564f6de417 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:06:27 +0100
Subject: [PATCH 28/44] Automatic next_node detection in
 simplified-expenses-checker

---
 .../simplified-expenses-checker.rb            | 110 ++++++------------
 .../simplified-expenses-checker-files.yml     |   2 +-
 2 files changed, 34 insertions(+), 78 deletions(-)

diff --git a/lib/smart_answer_flows/simplified-expenses-checker.rb b/lib/smart_answer_flows/simplified-expenses-checker.rb
index daaf433c316..d70e2e461af 100644
--- a/lib/smart_answer_flows/simplified-expenses-checker.rb
+++ b/lib/smart_answer_flows/simplified-expenses-checker.rb
@@ -66,25 +66,19 @@ def define
           response == "none" ? [] : response.split(",")
         end
 
-        permitted_next_nodes = [
-          :you_cant_use_result,
-          :buying_new_vehicle?,
-          :hours_work_home?,
-          :deduct_from_premises?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           next_question = nil
           if response == "none"
-            :you_cant_use_result
+            outcome :you_cant_use_result
           else
             responses = response.split(",")
             raise InvalidResponse if response =~ /live_on_business_premises.*?using_home_for_business/
             if (responses & ["car_or_van", "motorcycle"]).any?
-              :buying_new_vehicle?
+              question :buying_new_vehicle?
             elsif responses.include?("using_home_for_business")
-              :hours_work_home?
+              question :hours_work_home?
             elsif responses.include?("live_on_business_premises")
-              :deduct_from_premises?
+              question :deduct_from_premises?
             end
           end
         end
@@ -95,19 +89,14 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_vehicle_green?,
-          :capital_allowances?,
-          :how_much_expect_to_claim?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == "yes"
-            :is_vehicle_green?
+            question :is_vehicle_green?
           else
             if is_existing_business
-              :capital_allowances?
+              question :capital_allowances?
             else
-              :how_much_expect_to_claim?
+              question :how_much_expect_to_claim?
             end
           end
         end
@@ -128,27 +117,21 @@ def define
           response == "yes" and (list_of_expenses & %w(using_home_for_business live_on_business_premises)).any?
         end
 
-        permitted_next_nodes = [
-          :hours_work_home?,
-          :deduct_from_premises?,
-          :capital_allowance_result,
-          :how_much_expect_to_claim?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == "yes"
             if (list_of_expenses & %w(using_home_for_business live_on_business_premises)).any?
               if list_of_expenses.include?("using_home_for_business")
                 # Q11
-                :hours_work_home?
+                question :hours_work_home?
               else
                 # Q13
-                :deduct_from_premises?
+                question :deduct_from_premises?
               end
             else
-              :capital_allowance_result
+              outcome :capital_allowance_result
             end
           else
-            :how_much_expect_to_claim?
+            question :how_much_expect_to_claim?
           end
         end
 
@@ -158,15 +141,11 @@ def define
       money_question :how_much_expect_to_claim? do
         save_input_as :vehicle_costs
 
-        permitted_next_nodes = [
-          :drive_business_miles_car_van?,
-          :drive_business_miles_motorcycle?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if list_of_expenses.include?("car_or_van")
-            :drive_business_miles_car_van?
+            question :drive_business_miles_car_van?
           else
-            :drive_business_miles_motorcycle?
+            question :drive_business_miles_motorcycle?
           end
         end
       end
@@ -219,14 +198,10 @@ def define
           vehicle_is_green ? nil : Money.new(dirty_vehicle_price * ( business_use_percent / 100))
         end
 
-        permitted_next_nodes = [
-          :drive_business_miles_car_van?,
-          :drive_business_miles_motorcycle?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           raise InvalidResponse if response.to_i > 100
           list_of_expenses.include?("car_or_van") ?
-            :drive_business_miles_car_van? : :drive_business_miles_motorcycle?
+            question(:drive_business_miles_car_van?) : question(:drive_business_miles_motorcycle?)
         end
       end
 
@@ -245,21 +220,15 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :drive_business_miles_motorcycle?,
-          :hours_work_home?,
-          :deduct_from_premises?,
-          :you_can_use_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if list_of_expenses.include?("motorcycle")
-            :drive_business_miles_motorcycle?
+            question :drive_business_miles_motorcycle?
           elsif list_of_expenses.include?("using_home_for_business")
-            :hours_work_home?
+            question :hours_work_home?
           elsif list_of_expenses.include?("live_on_business_premises")
-            :deduct_from_premises?
+            question :deduct_from_premises?
           else
-            :you_can_use_result
+            outcome :you_can_use_result
           end
         end
       end
@@ -270,18 +239,13 @@ def define
           Money.new(response.gsub(",", "").to_f * 0.24)
         end
 
-        permitted_next_nodes = [
-          :hours_work_home?,
-          :deduct_from_premises?,
-          :you_can_use_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if list_of_expenses.include?("using_home_for_business")
-            :hours_work_home?
+            question :hours_work_home?
           elsif list_of_expenses.include?("live_on_business_premises")
-            :deduct_from_premises?
+            question :deduct_from_premises?
           else
-            :you_can_use_result
+            outcome :you_can_use_result
           end
         end
       end
@@ -303,18 +267,14 @@ def define
           Money.new(amount)
         end
 
-        permitted_next_nodes = [
-          :you_cant_use_result,
-          :current_claim_amount_home?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           hours = response.to_i
           if hours < 1
             raise SmartAnswer::InvalidResponse
           elsif hours < 25
-            :you_cant_use_result
+            outcome :you_cant_use_result
           else
-            :current_claim_amount_home?
+            question :current_claim_amount_home?
           end
         end
       end
@@ -323,12 +283,8 @@ def define
       money_question :current_claim_amount_home? do
         save_input_as :home_costs
 
-        permitted_next_nodes = [
-          :deduct_from_premises?,
-          :you_can_use_result
-        ]
-        next_node(permitted: permitted_next_nodes) do
-          list_of_expenses.include?("live_on_business_premises") ? :deduct_from_premises? : :you_can_use_result
+        next_node(permitted: :auto) do
+          list_of_expenses.include?("live_on_business_premises") ? question(:deduct_from_premises?) : outcome(:you_can_use_result)
         end
 
       end
diff --git a/test/data/simplified-expenses-checker-files.yml b/test/data/simplified-expenses-checker-files.yml
index fedbb96446b..c49d7c1b041 100644
--- a/test/data/simplified-expenses-checker-files.yml
+++ b/test/data/simplified-expenses-checker-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/simplified-expenses-checker.rb: 2c7afb8a135da70c651677f2d3cb80a2
+lib/smart_answer_flows/simplified-expenses-checker.rb: 1d2af01bc840e9968dba39937c8eb437
 test/data/simplified-expenses-checker-questions-and-responses.yml: de8747e3d768e4095264a214cdb58d0b
 test/data/simplified-expenses-checker-responses-and-expected-results.yml: 239e9c4e6fda064faecff3403fc3033d
 lib/smart_answer_flows/simplified-expenses-checker/outcomes/capital_allowance_result.govspeak.erb: 0f738efb15d8d63ebb9f824eb4010744

From 5bcaff8958adc93bc336f3042386bafb0e3eaa1a Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:09:14 +0100
Subject: [PATCH 29/44] Automatic next_node detection in state-pension-age

---
 lib/smart_answer_flows/state-pension-age.rb | 29 ++++++---------------
 test/data/state-pension-age-files.yml       |  2 +-
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/lib/smart_answer_flows/state-pension-age.rb b/lib/smart_answer_flows/state-pension-age.rb
index a090d5d8ee1..51e4f86fb55 100644
--- a/lib/smart_answer_flows/state-pension-age.rb
+++ b/lib/smart_answer_flows/state-pension-age.rb
@@ -13,11 +13,8 @@ def define
 
         save_input_as :which_calculation
 
-        permitted_next_nodes = [
-          :dob_age?
-        ]
-        next_node(permitted: permitted_next_nodes) do
-          :dob_age?
+        next_node(permitted: :auto) do
+          question :dob_age?
         end
       end
 
@@ -27,20 +24,15 @@ def define
 
         validate { |response| response <= Date.today }
 
-        permitted_next_nodes = [
-          :bus_pass_result,
-          :gender?
-        ]
-
         calculate :calculator do |response|
           Calculators::StatePensionAgeCalculator.new(dob: response)
         end
 
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if which_calculation == 'age'
-            :gender?
+            question :gender?
           else
-            :bus_pass_result
+            outcome :bus_pass_result
           end
         end
       end
@@ -50,18 +42,13 @@ def define
         option :male
         option :female
 
-        permitted_next_nodes = [
-          :not_yet_reached_sp_age,
-          :has_reached_sp_age
-        ]
-
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           calculator.gender = response.to_sym
 
           if calculator.before_state_pension_date?
-            :not_yet_reached_sp_age
+            outcome :not_yet_reached_sp_age
           else
-            :has_reached_sp_age
+            outcome :has_reached_sp_age
           end
         end
       end
diff --git a/test/data/state-pension-age-files.yml b/test/data/state-pension-age-files.yml
index 34c8810145b..1d5450d15a4 100644
--- a/test/data/state-pension-age-files.yml
+++ b/test/data/state-pension-age-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/state-pension-age.rb: e8727b1ae5d1cde7b2399a1973d93a3a
+lib/smart_answer_flows/state-pension-age.rb: 66ddcd2e965a02c533e45739d10d589e
 test/data/state-pension-age-questions-and-responses.yml: 6cf2d7052e044c4367b943077205f882
 test/data/state-pension-age-responses-and-expected-results.yml: 54283e77f05bd42775d6d3d1f1fc4380
 lib/smart_answer_flows/state-pension-age/outcomes/bus_pass_result.govspeak.erb: 9dd637a833ddcf0402a6a38e55fb2ace

From 6299e7059354cb73a2601b346f991b560cdd9c32 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:11:36 +0100
Subject: [PATCH 30/44] Automatic next_node detection in
 state-pension-through-partner

---
 .../state-pension-through-partner.rb          | 55 ++++++-------------
 .../state-pension-through-partner-files.yml   |  2 +-
 2 files changed, 18 insertions(+), 39 deletions(-)

diff --git a/lib/smart_answer_flows/state-pension-through-partner.rb b/lib/smart_answer_flows/state-pension-through-partner.rb
index a1a9a919419..8d7a7506779 100644
--- a/lib/smart_answer_flows/state-pension-through-partner.rb
+++ b/lib/smart_answer_flows/state-pension-through-partner.rb
@@ -38,15 +38,11 @@ def define
           "£#{rate}"
         end
 
-        permitted_next_nodes = [
-          :what_is_your_gender?,
-          :when_will_you_reach_pension_age?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'divorced'
-            :what_is_your_gender?
+            question :what_is_your_gender?
           else
-            :when_will_you_reach_pension_age?
+            question :when_will_you_reach_pension_age?
           end
         end
       end
@@ -76,18 +72,13 @@ def define
           answers == [:widow] && response == "your_pension_age_before_specific_date"
         end
 
-        permitted_next_nodes = [
-          :what_is_your_gender?,
-          :when_will_your_partner_reach_pension_age?,
-          :widow_and_old_pension_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if widow_and_new_pension
-            :what_is_your_gender?
+            question :what_is_your_gender?
           elsif widow_and_old_pension
-            :widow_and_old_pension_outcome
+            outcome :widow_and_old_pension_outcome
           else
-            :when_will_your_partner_reach_pension_age?
+            question :when_will_your_partner_reach_pension_age?
           end
         end
       end
@@ -114,18 +105,13 @@ def define
           answers == [:old1, :old2, :new3] || answers == [:new1, :old2, :new3]
         }
 
-        permitted_next_nodes = [
-          :current_rules_national_insurance_no_state_pension_outcome,
-          :current_rules_no_additional_pension_outcome,
-          :what_is_your_gender?
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if current_rules_no_additional_pension
-            :current_rules_no_additional_pension_outcome
+            outcome :current_rules_no_additional_pension_outcome
           elsif current_rules_national_insurance_no_state_pension
-            :current_rules_national_insurance_no_state_pension_outcome
+            outcome :current_rules_national_insurance_no_state_pension_outcome
           else
-            :what_is_your_gender?
+            question :what_is_your_gender?
           end
         end
       end
@@ -137,28 +123,21 @@ def define
 
         save_input_as :gender
 
-        permitted_next_nodes = [
-          :age_dependent_pension_outcome,
-          :impossibility_due_to_divorce_outcome,
-          :impossibility_to_increase_pension_outcome,
-          :married_woman_and_state_pension_outcome,
-          :married_woman_no_state_pension_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'male_gender'
             if marital_status == 'divorced'
-              :impossibility_due_to_divorce_outcome
+              outcome :impossibility_due_to_divorce_outcome
             else
-              :impossibility_to_increase_pension_outcome
+              outcome :impossibility_to_increase_pension_outcome
             end
           when 'female_gender'
             if marital_status == 'divorced'
-              :age_dependent_pension_outcome
+              outcome :age_dependent_pension_outcome
             elsif marital_status == 'widowed'
-              :married_woman_and_state_pension_outcome
+              outcome :married_woman_and_state_pension_outcome
             else
-              :married_woman_no_state_pension_outcome
+              outcome :married_woman_no_state_pension_outcome
             end
           end
         end
diff --git a/test/data/state-pension-through-partner-files.yml b/test/data/state-pension-through-partner-files.yml
index 03fc8146c82..7ce2d8e35d2 100644
--- a/test/data/state-pension-through-partner-files.yml
+++ b/test/data/state-pension-through-partner-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/state-pension-through-partner.rb: 99a9aa83c13664ec84c520b22114a493
+lib/smart_answer_flows/state-pension-through-partner.rb: 8ebe38885033b83687a0805519cf33c7
 test/data/state-pension-through-partner-questions-and-responses.yml: 256f0f1136d388a674a0732173da6c1a
 test/data/state-pension-through-partner-responses-and-expected-results.yml: fcf56e5687c592c8693f62f529bc939e
 lib/smart_answer_flows/state-pension-through-partner/outcomes/_increase_retirement_income.govspeak.erb: 2391bf6e80d1aa4d0d4258030b4f4e00

From 498c4c26d2a909039f4b9b2a824f46d9cb14778f Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:12:54 +0100
Subject: [PATCH 31/44] Automatic next_node detection in state-pension-topup

---
 lib/smart_answer_flows/state-pension-topup.rb | 20 ++++++-------------
 test/data/state-pension-topup-files.yml       |  2 +-
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/lib/smart_answer_flows/state-pension-topup.rb b/lib/smart_answer_flows/state-pension-topup.rb
index 2bc29038265..2a8bff908c7 100644
--- a/lib/smart_answer_flows/state-pension-topup.rb
+++ b/lib/smart_answer_flows/state-pension-topup.rb
@@ -18,15 +18,11 @@ def define
           calculator.too_young?(response)
         end
 
-        permitted_next_nodes = [
-          :gender?,
-          :outcome_pension_age_not_reached
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if too_young
-            :outcome_pension_age_not_reached
+            outcome :outcome_pension_age_not_reached
           else
-            :gender?
+            question :gender?
           end
         end
       end
@@ -42,15 +38,11 @@ def define
           calculator.too_young?(date_of_birth, response)
         end
 
-        permitted_next_nodes = [
-          :how_much_extra_per_week?,
-          :outcome_pension_age_not_reached
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           if male_and_too_young
-            :outcome_pension_age_not_reached
+            outcome :outcome_pension_age_not_reached
           else
-            :how_much_extra_per_week?
+            question :how_much_extra_per_week?
           end
         end
       end
diff --git a/test/data/state-pension-topup-files.yml b/test/data/state-pension-topup-files.yml
index 58e0d68bad3..def752a70ba 100644
--- a/test/data/state-pension-topup-files.yml
+++ b/test/data/state-pension-topup-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/state-pension-topup.rb: 588abd953a7a80e1ead751394e72ab0c
+lib/smart_answer_flows/state-pension-topup.rb: 867f75a757162167087d5c152c47d07a
 test/data/state-pension-topup-questions-and-responses.yml: f4f609a6e989f166616a05435c6993aa
 test/data/state-pension-topup-responses-and-expected-results.yml: 1207c6118839a3b13810038c57a20d4a
 lib/smart_answer_flows/state-pension-topup/outcomes/outcome_pension_age_not_reached.govspeak.erb: 558d49584fe1ece4d36427740d381273

From 580af6ec600a7d86c95e104f6c541febe5bdade6 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:14:33 +0100
Subject: [PATCH 32/44] Automatic next_node detection in
 student-finance-calculator

---
 .../student-finance-calculator.rb             | 26 ++++++-------------
 .../data/student-finance-calculator-files.yml |  2 +-
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/lib/smart_answer_flows/student-finance-calculator.rb b/lib/smart_answer_flows/student-finance-calculator.rb
index ec07bf5c730..d4559878fa5 100644
--- a/lib/smart_answer_flows/student-finance-calculator.rb
+++ b/lib/smart_answer_flows/student-finance-calculator.rb
@@ -38,19 +38,14 @@ def define
           Money.new(response)
         end
 
-        permitted_next_nodes = [
-          :where_will_you_live_while_studying?,
-          :do_any_of_the_following_apply_all_uk_students?,
-          :outcome_eu_students
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case course_type
           when 'uk-full-time'
-            :where_will_you_live_while_studying?
+            question :where_will_you_live_while_studying?
           when 'uk-part-time'
-            :do_any_of_the_following_apply_all_uk_students?
+            question :do_any_of_the_following_apply_all_uk_students?
           when 'eu-full-time', 'eu-part-time'
-            :outcome_eu_students
+            outcome :outcome_eu_students
           end
         end
 
@@ -124,19 +119,14 @@ def define
 
         save_input_as :course_studied
 
-        permitted_next_nodes = [
-          :outcome_uk_full_time_students,
-          :outcome_uk_all_students,
-          :outcome_eu_students
-        ]
-        next_node(permitted: permitted_next_nodes) do
+        next_node(permitted: :auto) do
           case course_type
           when 'uk-full-time'
-            :outcome_uk_full_time_students
+            outcome :outcome_uk_full_time_students
           when 'uk-part-time'
-            :outcome_uk_all_students
+            outcome :outcome_uk_all_students
           else
-            :outcome_eu_students
+            outcome :outcome_eu_students
           end
         end
 
diff --git a/test/data/student-finance-calculator-files.yml b/test/data/student-finance-calculator-files.yml
index 7f89779ae4d..408f8686b40 100644
--- a/test/data/student-finance-calculator-files.yml
+++ b/test/data/student-finance-calculator-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/student-finance-calculator.rb: 7dad8190af5f892d12312b7f9ad30d32
+lib/smart_answer_flows/student-finance-calculator.rb: f5dacee3808997e0f472cafe7a3575fa
 test/data/student-finance-calculator-questions-and-responses.yml: 8f68ec47644191cd01864ba288acf7ec
 test/data/student-finance-calculator-responses-and-expected-results.yml: 4d17ae39630843d360460ef2131c5980
 lib/smart_answer_flows/student-finance-calculator/outcomes/outcome_eu_students.govspeak.erb: b74eb38ff2a8534fb5fc8b0175fabf68

From f85f32ddc4e6b8c65cf6c8c86df88380dcfa5865 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:18:42 +0100
Subject: [PATCH 33/44] Automatic next_node detection in student-finance-forms

---
 .../student-finance-forms.rb                  | 164 ++++++------------
 test/data/student-finance-forms-files.yml     |   2 +-
 2 files changed, 54 insertions(+), 112 deletions(-)

diff --git a/lib/smart_answer_flows/student-finance-forms.rb b/lib/smart_answer_flows/student-finance-forms.rb
index 3256c9d776f..7dd3014b38f 100644
--- a/lib/smart_answer_flows/student-finance-forms.rb
+++ b/lib/smart_answer_flows/student-finance-forms.rb
@@ -14,22 +14,16 @@ def define
 
         save_input_as :type_of_student
 
-        permitted_next_nodes = [
-          :form_needed_for_1?,
-          :form_needed_for_2?,
-          :what_year_full_time?,
-          :what_year_part_time?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'uk-full-time'
-            :form_needed_for_1?
+            question :form_needed_for_1?
           when 'uk-part-time'
-            :form_needed_for_2?
+            question :form_needed_for_2?
           when 'eu-full-time'
-            :what_year_full_time?
+            question :what_year_full_time?
           when 'eu-part-time'
-            :what_year_part_time?
+            question :what_year_part_time?
           end
         end
       end
@@ -46,22 +40,16 @@ def define
 
         save_input_as :form_needed_for_1
 
-        permitted_next_nodes = [
-          :outcome_ccg_expenses,
-          :outcome_dsa_expenses,
-          :outcome_travel,
-          :what_year_full_time?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'dsa-expenses'
-            :outcome_dsa_expenses
+            outcome :outcome_dsa_expenses
           when 'ccg-expenses'
-            :outcome_ccg_expenses
+            outcome :outcome_ccg_expenses
           when 'travel-grant'
-            :outcome_travel
+            outcome :outcome_travel
           else
-            :what_year_full_time?
+            question :what_year_full_time?
           end
         end
       end
@@ -74,16 +62,12 @@ def define
 
         save_input_as :form_needed_for_2
 
-        permitted_next_nodes = [
-          :outcome_dsa_expenses,
-          :what_year_part_time?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'dsa-expenses'
-            :outcome_dsa_expenses
+            outcome :outcome_dsa_expenses
           else
-            :what_year_part_time?
+            question :what_year_part_time?
           end
         end
       end
@@ -94,53 +78,42 @@ def define
 
         save_input_as :what_year
 
-        permitted_next_nodes = [
-          :continuing_student?,
-          :outcome_ccg_1516,
-          :outcome_ccg_1617,
-          :outcome_dsa_1516,
-          :outcome_dsa_1617,
-          :outcome_parent_partner_1516,
-          :outcome_parent_partner_1617,
-          :outcome_proof_identity_1516,
-          :outcome_proof_identity_1617
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case type_of_student
           when 'eu-full-time'
-            :continuing_student?
+            question :continuing_student?
           when 'uk-full-time'
             case form_needed_for_1
             when 'proof-identity'
               case response
               when 'year-1516'
-                :outcome_proof_identity_1516
+                outcome :outcome_proof_identity_1516
               when 'year-1617'
-                :outcome_proof_identity_1617
+                outcome :outcome_proof_identity_1617
               end
             when 'income-details'
               case response
               when 'year-1516'
-                :outcome_parent_partner_1516
+                outcome :outcome_parent_partner_1516
               when 'year-1617'
-                :outcome_parent_partner_1617
+                outcome :outcome_parent_partner_1617
               end
             when 'apply-dsa'
               case response
               when 'year-1516'
-                :outcome_dsa_1516
+                outcome :outcome_dsa_1516
               when 'year-1617'
-                :outcome_dsa_1617
+                outcome :outcome_dsa_1617
               end
             when 'apply-ccg'
               case response
               when 'year-1516'
-                :outcome_ccg_1516
+                outcome :outcome_ccg_1516
               when 'year-1617'
-                :outcome_ccg_1617
+                outcome :outcome_ccg_1617
               end
             when 'apply-loans-grants'
-              :continuing_student?
+              question :continuing_student?
             end
           end
         end
@@ -152,35 +125,28 @@ def define
 
         save_input_as :what_year
 
-        permitted_next_nodes = [
-          :continuing_student?,
-          :outcome_dsa_1415_pt,
-          :outcome_dsa_1516_pt,
-          :outcome_proof_identity_1415,
-          :outcome_proof_identity_1516
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case type_of_student
           when 'eu-part-time'
-            :continuing_student?
+            question :continuing_student?
           when 'uk-part-time'
             case form_needed_for_2
             when 'proof-identity'
               case response
               when 'year-1415'
-                :outcome_proof_identity_1415
+                outcome :outcome_proof_identity_1415
               when 'year-1516'
-                :outcome_proof_identity_1516
+                outcome :outcome_proof_identity_1516
               end
             when 'apply-dsa'
               case response
               when 'year-1415'
-                :outcome_dsa_1415_pt
+                outcome :outcome_dsa_1415_pt
               when 'year-1516'
-                :outcome_dsa_1516_pt
+                outcome :outcome_dsa_1516_pt
               end
             when 'apply-loans-grants'
-              :continuing_student?
+              question :continuing_student?
             end
           end
         end
@@ -192,38 +158,23 @@ def define
 
         save_input_as :continuing_student
 
-        permitted_next_nodes = [
-          :outcome_eu_ft_1516_continuing,
-          :outcome_eu_ft_1516_new,
-          :outcome_eu_ft_1617_continuing,
-          :outcome_eu_ft_1617_new,
-          :outcome_eu_pt_1415_continuing,
-          :outcome_eu_pt_1415_new,
-          :outcome_eu_pt_1516_continuing,
-          :outcome_eu_pt_1516_new,
-          :outcome_uk_ft_1516_continuing,
-          :outcome_uk_ft_1516_new,
-          :outcome_uk_ft_1617_continuing,
-          :outcome_uk_ft_1617_new,
-          :pt_course_start?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case type_of_student
           when 'eu-full-time'
             case what_year
             when 'year-1516'
               case response
               when 'continuing-student'
-                :outcome_eu_ft_1516_continuing
+                outcome :outcome_eu_ft_1516_continuing
               when 'new-student'
-                :outcome_eu_ft_1516_new
+                outcome :outcome_eu_ft_1516_new
               end
             when 'year-1617'
               case response
               when 'continuing-student'
-                :outcome_eu_ft_1617_continuing
+                outcome :outcome_eu_ft_1617_continuing
               when 'new-student'
-                :outcome_eu_ft_1617_new
+                outcome :outcome_eu_ft_1617_new
               end
             end
           when 'eu-part-time'
@@ -231,16 +182,16 @@ def define
             when 'year-1415'
               case response
               when 'continuing-student'
-                :outcome_eu_pt_1415_continuing
+                outcome :outcome_eu_pt_1415_continuing
               when 'new-student'
-                :outcome_eu_pt_1415_new
+                outcome :outcome_eu_pt_1415_new
               end
             when 'year-1516'
               case response
               when 'continuing-student'
-                :outcome_eu_pt_1516_continuing
+                outcome :outcome_eu_pt_1516_continuing
               when 'new-student'
-                :outcome_eu_pt_1516_new
+                outcome :outcome_eu_pt_1516_new
               end
             end
           when 'uk-full-time'
@@ -249,21 +200,21 @@ def define
               when 'year-1516'
                 case response
                 when 'continuing-student'
-                  :outcome_uk_ft_1516_continuing
+                  outcome :outcome_uk_ft_1516_continuing
                 when 'new-student'
-                  :outcome_uk_ft_1516_new
+                  outcome :outcome_uk_ft_1516_new
                 end
               when 'year-1617'
                 case response
                 when 'continuing-student'
-                  :outcome_uk_ft_1617_continuing
+                  outcome :outcome_uk_ft_1617_continuing
                 when 'new-student'
-                  :outcome_uk_ft_1617_new
+                  outcome :outcome_uk_ft_1617_new
                 end
               end
             end
           when 'uk-part-time'
-            :pt_course_start?
+            question :pt_course_start?
           end
         end
       end
@@ -272,27 +223,18 @@ def define
         option 'course-start-before-01092012'
         option 'course-start-after-01092012'
 
-        permitted_next_nodes = [
-          :outcome_uk_pt_1415_continuing,
-          :outcome_uk_pt_1415_grant,
-          :outcome_uk_pt_1415_new,
-          :outcome_uk_pt_1516_continuing,
-          :outcome_uk_pt_1516_new,
-          :outcome_uk_ptgc_1516_grant,
-          :outcome_uk_ptgn_1516_grant
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case what_year
           when 'year-1415'
             case response
             when 'course-start-before-01092012'
-              :outcome_uk_pt_1415_grant
+              outcome :outcome_uk_pt_1415_grant
             when 'course-start-after-01092012'
               case continuing_student
               when 'continuing-student'
-                :outcome_uk_pt_1415_continuing
+                outcome :outcome_uk_pt_1415_continuing
               when 'new-student'
-                :outcome_uk_pt_1415_new
+                outcome :outcome_uk_pt_1415_new
               end
             end
           when 'year-1516'
@@ -300,16 +242,16 @@ def define
             when 'course-start-before-01092012'
               case continuing_student
               when 'continuing-student'
-                :outcome_uk_ptgc_1516_grant
+                outcome :outcome_uk_ptgc_1516_grant
               when 'new-student'
-                :outcome_uk_ptgn_1516_grant
+                outcome :outcome_uk_ptgn_1516_grant
               end
             when 'course-start-after-01092012'
               case continuing_student
               when 'continuing-student'
-                :outcome_uk_pt_1516_continuing
+                outcome :outcome_uk_pt_1516_continuing
               when 'new-student'
-                :outcome_uk_pt_1516_new
+                outcome :outcome_uk_pt_1516_new
               end
             end
           end
diff --git a/test/data/student-finance-forms-files.yml b/test/data/student-finance-forms-files.yml
index 10707343934..aef3b0d363d 100644
--- a/test/data/student-finance-forms-files.yml
+++ b/test/data/student-finance-forms-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/student-finance-forms.rb: d0d63f0fca41c6f60926301c309e3fff
+lib/smart_answer_flows/student-finance-forms.rb: 3fe33aea8be8ec74deeaad825f396a63
 test/data/student-finance-forms-questions-and-responses.yml: 59efd7bff0de61c0a9e707415cca4608
 test/data/student-finance-forms-responses-and-expected-results.yml: 9e1a5b712cf384edb874d8902debe279
 lib/smart_answer_flows/student-finance-forms/outcomes/_circumstances_changed_co2_form.govspeak.erb: 236d81f3660a1958bb0dd3a8f229baf4

From 4f032240ae7f0a6c9ebfac308551973f87d3d198 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:25:50 +0100
Subject: [PATCH 34/44] Automatic next_node detection in towing-rules

---
 lib/smart_answer_flows/towing-rules.rb | 182 ++++++++-----------------
 test/data/towing-rules-files.yml       |   2 +-
 2 files changed, 56 insertions(+), 128 deletions(-)

diff --git a/lib/smart_answer_flows/towing-rules.rb b/lib/smart_answer_flows/towing-rules.rb
index 8498785b6bc..b1688b71a28 100644
--- a/lib/smart_answer_flows/towing-rules.rb
+++ b/lib/smart_answer_flows/towing-rules.rb
@@ -16,25 +16,18 @@ def define
         option "minibus"
         option "bus"
 
-        permitted_next_nodes = [
-          :existing_towing_entitlements?,
-          :medium_sized_vehicle_licenceholder?,
-          :existing_large_vehicle_licence?,
-          :car_licence_before_jan_1997?,
-          :bus_licenceholder?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'car-or-light-vehicle'
-            :existing_towing_entitlements? #Q2
+            question :existing_towing_entitlements? #Q2
           when 'medium-sized-vehicle'
-            :medium_sized_vehicle_licenceholder? #Q8
+            question :medium_sized_vehicle_licenceholder? #Q8
           when 'large-vehicle'
-            :existing_large_vehicle_licence? #Q20
+            question :existing_large_vehicle_licence? #Q20
           when 'minibus'
-            :car_licence_before_jan_1997? #Q25
+            question :car_licence_before_jan_1997? #Q25
           when 'bus'
-            :bus_licenceholder? #Q36
+            question :bus_licenceholder? #Q36
           end
         end
       end
@@ -44,16 +37,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :how_long_entitlements?,
-          :date_licence_was_issued?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_long_entitlements? #Q2A
+            question :how_long_entitlements? #Q2A
           when 'no'
-            :date_licence_was_issued? #Q5
+            question :date_licence_was_issued? #Q5
           end
         end
       end
@@ -63,16 +52,12 @@ def define
         option "before-19-Jan-2013"
         option "after-19-Jan-2013"
 
-        permitted_next_nodes = [
-          :car_light_vehicle_entitlement,
-          :full_entitlement
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'before-19-Jan-2013'
-            :car_light_vehicle_entitlement #A3
+            outcome :car_light_vehicle_entitlement #A3
           when 'after-19-Jan-2013'
-            :full_entitlement #A4
+            outcome :full_entitlement #A4
           end
         end
       end
@@ -82,16 +67,12 @@ def define
         option "licence-issued-before-19-Jan-2013"
         option "licence-issued-after-19-Jan-2013"
 
-        permitted_next_nodes = [
-          :limited_trailer_entitlement,
-          :limited_trailer_entitlement_2013
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'licence-issued-before-19-Jan-2013'
-            :limited_trailer_entitlement #A6
+            outcome :limited_trailer_entitlement #A6
           when 'licence-issued-after-19-Jan-2013'
-            :limited_trailer_entitlement_2013 #A7
+            outcome :limited_trailer_entitlement_2013 #A7
           end
         end
       end
@@ -103,16 +84,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :how_old_are_you_msv?,
-          :existing_large_vehicle_towing_entitlements?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :how_old_are_you_msv? #Q9
+            question :how_old_are_you_msv? #Q9
           when 'no'
-            :existing_large_vehicle_towing_entitlements? #Q12
+            question :existing_large_vehicle_towing_entitlements? #Q12
           end
         end
       end
@@ -122,16 +99,12 @@ def define
         option "under-21"
         option "21-or-over"
 
-        permitted_next_nodes = [
-          :limited_conditional_trailer_entitlement_msv,
-          :limited_trailer_entitlement_msv
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'under-21'
-            :limited_conditional_trailer_entitlement_msv #A10
+            outcome :limited_conditional_trailer_entitlement_msv #A10
           when '21-or-over'
-            :limited_trailer_entitlement_msv #A11
+            outcome :limited_trailer_entitlement_msv #A11
           end
         end
       end
@@ -141,16 +114,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :included_entitlement_msv,
-          :date_licence_was_issued_msv?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :included_entitlement_msv #A13
+            outcome :included_entitlement_msv #A13
           when 'no'
-            :date_licence_was_issued_msv? #Q14
+            question :date_licence_was_issued_msv? #Q14
           end
         end
       end
@@ -160,16 +129,12 @@ def define
         option "before-jan-1997"
         option "from-jan-1997"
 
-        permitted_next_nodes = [
-          :full_entitlement_msv,
-          :how_old_are_you_msv_2?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'before-jan-1997'
-            :full_entitlement_msv #A15
+            outcome :full_entitlement_msv #A15
           when 'from-jan-1997'
-            :how_old_are_you_msv_2? #Q16
+            question :how_old_are_you_msv_2? #Q16
           end
         end
       end
@@ -180,19 +145,14 @@ def define
         option "under-21"
         option "21-or-over"
 
-        permitted_next_nodes = [
-          :too_young_msv,
-          :apply_for_provisional_with_exceptions_msv,
-          :apply_for_provisional_msv
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'under-18'
-            :too_young_msv #A17
+            outcome :too_young_msv #A17
           when 'under-21'
-            :apply_for_provisional_with_exceptions_msv #A18
+            outcome :apply_for_provisional_with_exceptions_msv #A18
           when '21-or-over'
-            :apply_for_provisional_msv #19
+            outcome :apply_for_provisional_msv #19
           end
         end
       end
@@ -204,16 +164,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :full_cat_c_entitlement,
-          :how_old_are_you_lv?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :full_cat_c_entitlement #A21
+            outcome :full_cat_c_entitlement #A21
           when 'no'
-            :how_old_are_you_lv? #Q22
+            question :how_old_are_you_lv? #Q22
           end
         end
       end
@@ -223,16 +179,12 @@ def define
         option "under-21"
         option "21-or-over"
 
-        permitted_next_nodes = [
-          :not_old_enough_lv,
-          :apply_for_provisional_lv
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'under-21'
-            :not_old_enough_lv #A23
+            outcome :not_old_enough_lv #A23
           when '21-or-over'
-            :apply_for_provisional_lv #A24
+            outcome :apply_for_provisional_lv #A24
           end
         end
       end
@@ -244,16 +196,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :full_entitlement_minibus,
-          :do_you_have_lv_or_bus_towing_entitlement?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :full_entitlement_minibus #A26
+            outcome :full_entitlement_minibus #A26
           when 'no'
-            :do_you_have_lv_or_bus_towing_entitlement? #Q27
+            question :do_you_have_lv_or_bus_towing_entitlement? #Q27
           end
         end
       end
@@ -263,16 +211,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :included_entitlement_minibus,
-          :full_minibus_licence?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :included_entitlement_minibus #A28
+            outcome :included_entitlement_minibus #A28
           when 'no'
-            :full_minibus_licence? #Q29
+            question :full_minibus_licence? #Q29
           end
         end
       end
@@ -282,16 +226,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :limited_towing_entitlement_minibus,
-          :how_old_are_you_minibus?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :limited_towing_entitlement_minibus #A30
+            outcome :limited_towing_entitlement_minibus #A30
           when 'no'
-            :how_old_are_you_minibus? #Q31
+            question :how_old_are_you_minibus? #Q31
           end
         end
       end
@@ -301,16 +241,12 @@ def define
         option "under-21"
         option "21-or-over"
 
-        permitted_next_nodes = [
-          :not_old_enough_minibus,
-          :limited_overall_entitlement_minibus
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'under-21'
-            :not_old_enough_minibus #A32
+            outcome :not_old_enough_minibus #A32
           when '21-or-over'
-            :limited_overall_entitlement_minibus #A34
+            outcome :limited_overall_entitlement_minibus #A34
           end
         end
       end
@@ -322,16 +258,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :full_entitlement_bus,
-          :how_old_are_you_bus?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :full_entitlement_bus #A37
+            outcome :full_entitlement_bus #A37
           when 'no'
-            :how_old_are_you_bus? #Q38
+            question :how_old_are_you_bus? #Q38
           end
         end
       end
@@ -341,16 +273,12 @@ def define
         option "under-21"
         option "21-or-over"
 
-        permitted_next_nodes = [
-          :not_old_enough_bus,
-          :apply_for_provisional_bus
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'under-21'
-            :not_old_enough_bus #A39
+            outcome :not_old_enough_bus #A39
           when '21-or-over'
-            :apply_for_provisional_bus #A40
+            outcome :apply_for_provisional_bus #A40
           end
         end
       end
diff --git a/test/data/towing-rules-files.yml b/test/data/towing-rules-files.yml
index 47d029f0af7..fdba64db676 100644
--- a/test/data/towing-rules-files.yml
+++ b/test/data/towing-rules-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/towing-rules.rb: e2fec908824ffbab77853aa57b9893e5
+lib/smart_answer_flows/towing-rules.rb: cd037b6b673cad53ada52c0410784a1f
 test/data/towing-rules-questions-and-responses.yml: 17c522939af1e14522972c8281466143
 test/data/towing-rules-responses-and-expected-results.yml: 36f51dce9501d1ee9e960d7ce2139298
 lib/smart_answer_flows/towing-rules/outcomes/apply_for_provisional_bus.govspeak.erb: 7e9f6d62486894f8537e09ea07b07a43

From d8b04218d19ccd5100d7f8cba736c74a561d0097 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:33:32 +0100
Subject: [PATCH 35/44] Automatic next_node detection in uk-benefits-abroad

---
 lib/smart_answer_flows/uk-benefits-abroad.rb | 426 ++++++-------------
 test/data/uk-benefits-abroad-files.yml       |   2 +-
 2 files changed, 137 insertions(+), 291 deletions(-)

diff --git a/lib/smart_answer_flows/uk-benefits-abroad.rb b/lib/smart_answer_flows/uk-benefits-abroad.rb
index bba4a550d9b..dd824f6dd03 100644
--- a/lib/smart_answer_flows/uk-benefits-abroad.rb
+++ b/lib/smart_answer_flows/uk-benefits-abroad.rb
@@ -77,44 +77,32 @@ def define
           end
         end
 
-        permitted_next_nodes = [
-          :db_how_long_abroad?,
-          :eligible_for_tax_credits?,
-          :esa_how_long_abroad?,
-          :iidb_already_claiming?,
-          :is_already_abroad_outcome,
-          :is_how_long_abroad?,
-          :jsa_how_long_abroad?,
-          :pension_already_abroad_outcome,
-          :pension_going_abroad_outcome,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if %w{winter_fuel_payment maternity_benefits child_benefit ssp bereavement_benefits}.include?(response)
-            :which_country?
+            question :which_country?
           elsif response == 'iidb'
-            :iidb_already_claiming?
+            question :iidb_already_claiming?
           elsif response == 'esa'
-            :esa_how_long_abroad?
+            question :esa_how_long_abroad?
           elsif response == 'disability_benefits'
-            :db_how_long_abroad?
+            question :db_how_long_abroad?
           elsif response == 'tax_credits'
-            :eligible_for_tax_credits?
+            question :eligible_for_tax_credits?
           elsif going_abroad
             if response == 'jsa'
-              :jsa_how_long_abroad? # Q3 going_abroad
+              question :jsa_how_long_abroad? # Q3 going_abroad
             elsif response == 'pension'
-              :pension_going_abroad_outcome # A2 going_abroad
+              outcome :pension_going_abroad_outcome # A2 going_abroad
             elsif response == 'income_support'
-              :is_how_long_abroad? # Q32 going_abroad
+              question :is_how_long_abroad? # Q32 going_abroad
             end
           elsif already_abroad
             if response == 'jsa'
-              :which_country?
+              question :which_country?
             elsif response == 'pension'
-              :pension_already_abroad_outcome # A2 already_abroad
+              outcome :pension_already_abroad_outcome # A2 already_abroad
             elsif response == 'income_support'
-              :is_already_abroad_outcome #A40 already_abroad
+              outcome :is_already_abroad_outcome #A40 already_abroad
             end
           end
         end
@@ -154,169 +142,128 @@ def define
           %w(barbados bermuda canada guernsey jersey israel jamaica mauritius new-zealand philippines turkey usa)).include?(response)
         end
 
-        permitted_next_nodes = [
-          :bb_already_abroad_eea_outcome,
-          :bb_already_abroad_other_outcome,
-          :bb_already_abroad_ss_outcome,
-          :bb_going_abroad_eea_outcome,
-          :bb_going_abroad_other_outcome,
-          :bb_going_abroad_ss_outcome,
-          :child_benefit_fy_already_abroad_outcome,
-          :child_benefit_fy_going_abroad_outcome,
-          :child_benefit_jtu_outcome,
-          :child_benefit_not_entitled_outcome,
-          :child_benefit_ss_outcome,
-          :db_already_abroad_other_outcome,
-          :db_claiming_benefits?,
-          :db_going_abroad_other_outcome,
-          :do_either_of_the_following_apply?,
-          :employer_paying_ni?,
-          :esa_already_abroad_eea_outcome,
-          :esa_already_abroad_other_outcome,
-          :esa_already_abroad_ss_outcome,
-          :esa_going_abroad_eea_outcome,
-          :esa_going_abroad_other_outcome,
-          :iidb_already_abroad_eea_outcome,
-          :iidb_already_abroad_other_outcome,
-          :iidb_already_abroad_ss_outcome,
-          :iidb_going_abroad_eea_outcome,
-          :iidb_going_abroad_other_outcome,
-          :iidb_going_abroad_ss_outcome,
-          :jsa_eea_already_abroad_outcome,
-          :jsa_eea_going_abroad_outcome,
-          :jsa_not_entitled_outcome,
-          :jsa_social_security_already_abroad_outcome,
-          :jsa_social_security_going_abroad_outcome,
-          :tax_credits_currently_claiming?,
-          :tax_credits_unlikely_outcome,
-          :wfp_eea_eligible_outcome,
-          :wfp_going_abroad_outcome,
-          :wfp_not_eligible_outcome,
-          :working_for_a_uk_employer?,
-          :working_for_uk_employer_ssp?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case benefit
           when 'jsa'
             if already_abroad && responded_with_eea_country
-              :jsa_eea_already_abroad_outcome # A3 already_abroad
+              outcome :jsa_eea_already_abroad_outcome # A3 already_abroad
             elsif already_abroad && social_security_countries_jsa
-              :jsa_social_security_already_abroad_outcome # A4 already_abroad
+              outcome :jsa_social_security_already_abroad_outcome # A4 already_abroad
             elsif going_abroad && responded_with_eea_country
-              :jsa_eea_going_abroad_outcome # A5 going_abroad
+              outcome :jsa_eea_going_abroad_outcome # A5 going_abroad
             elsif going_abroad && social_security_countries_jsa
-              :jsa_social_security_going_abroad_outcome # A6 going_abroad
+              outcome :jsa_social_security_going_abroad_outcome # A6 going_abroad
             else
-              :jsa_not_entitled_outcome # A7 going_abroad and A5 already_abroad
+              outcome :jsa_not_entitled_outcome # A7 going_abroad and A5 already_abroad
             end
           when 'maternity_benefits'
             if responded_with_eea_country
-              :working_for_a_uk_employer? # Q8 going_abroad and Q7 already_abroad
+              question :working_for_a_uk_employer? # Q8 going_abroad and Q7 already_abroad
             else
-              :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad
+              question :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad
             end
           when 'winter_fuel_payment'
             if responded_with_eea_country
               if going_abroad
-                :wfp_going_abroad_outcome # A9 going_abroad
+                outcome :wfp_going_abroad_outcome # A9 going_abroad
               else
-                :wfp_eea_eligible_outcome # A7 already_abroad
+                outcome :wfp_eea_eligible_outcome # A7 already_abroad
               end
             else
-              :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad
+              outcome :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad
             end
           when 'child_benefit'
             if responded_with_eea_country
-              :do_either_of_the_following_apply? # Q13 going_abroad and Q12 already_abroad
+              question :do_either_of_the_following_apply? # Q13 going_abroad and Q12 already_abroad
             elsif responded_with_former_yugoslavia
               if going_abroad
-                :child_benefit_fy_going_abroad_outcome # A14 going_abroad
+                outcome :child_benefit_fy_going_abroad_outcome # A14 going_abroad
               else
-                :child_benefit_fy_already_abroad_outcome # A12 already_abroad
+                outcome :child_benefit_fy_already_abroad_outcome # A12 already_abroad
               end
             elsif %w(barbados canada guernsey israel jersey mauritius new-zealand).include?(response)
-              :child_benefit_ss_outcome # A15 going_abroad and A13 already_abroad
+              outcome :child_benefit_ss_outcome # A15 going_abroad and A13 already_abroad
             elsif %w(jamaica turkey usa).include?(response)
-              :child_benefit_jtu_outcome # A14 already_abroad
+              outcome :child_benefit_jtu_outcome # A14 already_abroad
             else
-              :child_benefit_not_entitled_outcome # A18 going_abroad and A16 already_abroad
+              outcome :child_benefit_not_entitled_outcome # A18 going_abroad and A16 already_abroad
             end
           when 'iidb'
             if going_abroad
               if responded_with_eea_country
-                :iidb_going_abroad_eea_outcome # A32 going_abroad
+                outcome :iidb_going_abroad_eea_outcome # A32 going_abroad
               elsif social_security_countries_iidb
-                :iidb_going_abroad_ss_outcome # A33 going_abroad
+                outcome :iidb_going_abroad_ss_outcome # A33 going_abroad
               else
-                :iidb_going_abroad_other_outcome # A34 going_abroad
+                outcome :iidb_going_abroad_other_outcome # A34 going_abroad
               end
             elsif already_abroad
               if responded_with_eea_country
-                :iidb_already_abroad_eea_outcome # A31 already_abroad
+                outcome :iidb_already_abroad_eea_outcome # A31 already_abroad
               elsif social_security_countries_iidb
-                :iidb_already_abroad_ss_outcome # A32 already_abroad
+                outcome :iidb_already_abroad_ss_outcome # A32 already_abroad
               else
-                :iidb_already_abroad_other_outcome # A33 already_abroad
+                outcome :iidb_already_abroad_other_outcome # A33 already_abroad
               end
             end
           when 'disability_benefits'
             if responded_with_eea_country
-              :db_claiming_benefits? # Q30 going_abroad and Q29 already_abroad
+              question :db_claiming_benefits? # Q30 going_abroad and Q29 already_abroad
             elsif going_abroad
-              :db_going_abroad_other_outcome # A36 going_abroad
+              outcome :db_going_abroad_other_outcome # A36 going_abroad
             else
-              :db_already_abroad_other_outcome # A35 already_abroad
+              outcome :db_already_abroad_other_outcome # A35 already_abroad
             end
           when 'ssp'
             if responded_with_eea_country
-              :working_for_uk_employer_ssp? # Q15 going_abroad and Q14 already_abroad
+              question :working_for_uk_employer_ssp? # Q15 going_abroad and Q14 already_abroad
             else
-              :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad
+              question :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad
             end
           when 'tax_credits'
             if responded_with_eea_country
-              :tax_credits_currently_claiming? # Q20 already_abroad
+              question :tax_credits_currently_claiming? # Q20 already_abroad
             else
-              :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
+              outcome :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
             end
           when 'esa'
             if going_abroad
               if responded_with_eea_country
-                :esa_going_abroad_eea_outcome # A29 going_abroad
+                outcome :esa_going_abroad_eea_outcome # A29 going_abroad
               elsif responded_with_former_yugoslavia
-                :esa_going_abroad_eea_outcome
+                outcome :esa_going_abroad_eea_outcome
               elsif %w(barbados guernsey israel jersey jamaica turkey usa).include?(response)
-                :esa_going_abroad_eea_outcome
+                outcome :esa_going_abroad_eea_outcome
               else
-                :esa_going_abroad_other_outcome # A30 going_abroad
+                outcome :esa_going_abroad_other_outcome # A30 going_abroad
               end
             elsif already_abroad
               if responded_with_eea_country
-                :esa_already_abroad_eea_outcome # A27 already_abroad
+                outcome :esa_already_abroad_eea_outcome # A27 already_abroad
               elsif responded_with_former_yugoslavia
-                :esa_already_abroad_ss_outcome # A28 already_abroad
+                outcome :esa_already_abroad_ss_outcome # A28 already_abroad
               elsif %w(barbados jersey guernsey jamaica turkey usa).include?(response)
-                :esa_already_abroad_ss_outcome
+                outcome :esa_already_abroad_ss_outcome
               else
-                :esa_already_abroad_other_outcome # A29 already_abroad
+                outcome :esa_already_abroad_other_outcome # A29 already_abroad
               end
             end
           when 'bereavement_benefits'
             if going_abroad
               if responded_with_eea_country
-                :bb_going_abroad_eea_outcome # A39 going_abroad
+                outcome :bb_going_abroad_eea_outcome # A39 going_abroad
               elsif social_security_countries_bereavement_benefits
-                :bb_going_abroad_ss_outcome # A40 going_abroad
+                outcome :bb_going_abroad_ss_outcome # A40 going_abroad
               else
-                :bb_going_abroad_other_outcome # A38 going_abroad
+                outcome :bb_going_abroad_other_outcome # A38 going_abroad
               end
             elsif already_abroad
               if responded_with_eea_country
-                :bb_already_abroad_eea_outcome # A37 already_abroad
+                outcome :bb_already_abroad_eea_outcome # A37 already_abroad
               elsif social_security_countries_bereavement_benefits
-                :bb_already_abroad_ss_outcome # A38 already_abroad
+                outcome :bb_already_abroad_ss_outcome # A38 already_abroad
               else
-                :bb_already_abroad_other_outcome # A39 already_abroad
+                outcome :bb_already_abroad_other_outcome # A39 already_abroad
               end
             end
           end
@@ -328,16 +275,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :eligible_for_smp?,
-          :maternity_benefits_maternity_allowance_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :eligible_for_smp? # Q9 going_abroad and Q8 already_abroad
+            question :eligible_for_smp? # Q9 going_abroad and Q8 already_abroad
           when 'no'
-            :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad
+            outcome :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad
           end
         end
       end
@@ -347,16 +290,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :maternity_benefits_eea_entitled_outcome,
-          :maternity_benefits_maternity_allowance_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :maternity_benefits_eea_entitled_outcome # A11 going_abroad and A9 already_abroad
+            outcome :maternity_benefits_eea_entitled_outcome # A11 going_abroad and A9 already_abroad
           when 'no'
-            :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad
+            outcome :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad
           end
         end
       end
@@ -366,44 +305,34 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :eligible_for_smp?,
-          :maternity_benefits_not_entitled_outcome,
-          :maternity_benefits_social_security_already_abroad_outcome,
-          :maternity_benefits_social_security_going_abroad_outcome,
-          :ssp_already_abroad_entitled_outcome,
-          :ssp_already_abroad_not_entitled_outcome,
-          :ssp_going_abroad_entitled_outcome,
-          :ssp_going_abroad_not_entitled_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           # SSP benefits
           if benefit == 'ssp'
             if going_abroad
               if response == 'yes'
-                :ssp_going_abroad_entitled_outcome # A19 going_abroad
+                outcome :ssp_going_abroad_entitled_outcome # A19 going_abroad
               else
-                :ssp_going_abroad_not_entitled_outcome # A20 going_abroad
+                outcome :ssp_going_abroad_not_entitled_outcome # A20 going_abroad
               end
             elsif already_abroad
               if response == 'yes'
-                :ssp_already_abroad_entitled_outcome # A17 already_abroad
+                outcome :ssp_already_abroad_entitled_outcome # A17 already_abroad
               else
-                :ssp_already_abroad_not_entitled_outcome # A18 already_abroad
+                outcome :ssp_already_abroad_not_entitled_outcome # A18 already_abroad
               end
             end
           else
             #not SSP benefits
             if response == 'yes'
-              :eligible_for_smp? # Q9 going_abroad and Q8 already_abroad
+              question :eligible_for_smp? # Q9 going_abroad and Q8 already_abroad
             elsif (countries_of_former_yugoslavia + %w(barbados guernsey jersey israel turkey)).include?(country)
               if already_abroad
-                :maternity_benefits_social_security_already_abroad_outcome # A10 already_abroad
+                outcome :maternity_benefits_social_security_already_abroad_outcome # A10 already_abroad
               else
-                :maternity_benefits_social_security_going_abroad_outcome # A12 going_abroad
+                outcome :maternity_benefits_social_security_going_abroad_outcome # A12 going_abroad
               end
             else
-              :maternity_benefits_not_entitled_outcome # A13 going_abroad and A11 already_abroad
+              outcome :maternity_benefits_not_entitled_outcome # A13 going_abroad and A11 already_abroad
             end
           end
         end
@@ -414,16 +343,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :child_benefit_entitled_outcome,
-          :child_benefit_not_entitled_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :child_benefit_entitled_outcome # A17 going_abroad and A15 already_abroad
+            outcome :child_benefit_entitled_outcome # A17 going_abroad and A15 already_abroad
           when 'no'
-            :child_benefit_not_entitled_outcome # A18 going_abroad and A16 already_abroad
+            outcome :child_benefit_not_entitled_outcome # A18 going_abroad and A16 already_abroad
           end
         end
       end
@@ -433,24 +358,18 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :ssp_already_abroad_entitled_outcome,
-          :ssp_already_abroad_not_entitled_outcome,
-          :ssp_going_abroad_entitled_outcome,
-          :ssp_going_abroad_not_entitled_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if going_abroad
             if response == 'yes'
-              :ssp_going_abroad_entitled_outcome # A19 going_abroad
+              outcome :ssp_going_abroad_entitled_outcome # A19 going_abroad
             else
-              :ssp_going_abroad_not_entitled_outcome # A20 going_abroad
+              outcome :ssp_going_abroad_not_entitled_outcome # A20 going_abroad
             end
           elsif already_abroad
             if response == 'yes'
-              :ssp_already_abroad_entitled_outcome # A17 already_abroad
+              outcome :ssp_already_abroad_entitled_outcome # A17 already_abroad
             else
-              :ssp_already_abroad_not_entitled_outcome # A18 already_abroad
+              outcome :ssp_already_abroad_not_entitled_outcome # A18 already_abroad
             end
           end
         end
@@ -462,19 +381,14 @@ def define
         option :cross_border_worker
         option :none_of_the_above
 
-        permitted_next_nodes = [
-          :tax_credits_crown_servant_outcome,
-          :tax_credits_cross_border_worker_outcome,
-          :tax_credits_how_long_abroad?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'crown_servant'
-            :tax_credits_crown_servant_outcome # A19 already_abroad
+            outcome :tax_credits_crown_servant_outcome # A19 already_abroad
           when 'cross_border_worker'
-            :tax_credits_cross_border_worker_outcome # A20 already_abroad
+            outcome :tax_credits_cross_border_worker_outcome # A20 already_abroad
           when 'none_of_the_above'
-            :tax_credits_how_long_abroad? # Q18 going_abroad and Q17 already_abroad
+            question :tax_credits_how_long_abroad? # Q18 going_abroad and Q17 already_abroad
           end
         end
       end
@@ -484,16 +398,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :which_country?,
-          :tax_credits_unlikely_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :which_country? # Q17
+            question :which_country? # Q17
           when 'no'
-            :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
+            outcome :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
           end
         end
       end
@@ -503,16 +413,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :tax_credits_eea_entitled_outcome,
-          :tax_credits_unlikely_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :tax_credits_eea_entitled_outcome # A22 already_abroad and A24 going_abroad
+            outcome :tax_credits_eea_entitled_outcome # A22 already_abroad and A24 going_abroad
           when 'no'
-            :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
+            outcome :tax_credits_unlikely_outcome # A21 already_abroad and A23 going_abroad
           end
         end
       end
@@ -523,16 +429,12 @@ def define
         option :tax_credits_medical_treatment
         option :tax_credits_death
 
-        permitted_next_nodes = [
-          :tax_credits_holiday_outcome,
-          :tax_credits_medical_death_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'tax_credits_holiday'
-            :tax_credits_holiday_outcome # A23 already_abroad and A25 going_abroad and A26 going_abroad
+            outcome :tax_credits_holiday_outcome # A23 already_abroad and A25 going_abroad and A26 going_abroad
           when 'tax_credits_medical_treatment', 'tax_credits_death'
-            :tax_credits_medical_death_outcome #A24 already_abroad
+            outcome :tax_credits_medical_death_outcome #A24 already_abroad
           end
         end
       end
@@ -542,16 +444,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :which_country?,
-          :iidb_maybe_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :which_country? # Shared question
+            question :which_country? # Shared question
           when 'no'
-            :iidb_maybe_outcome # A30 already_abroad and A31 going_abroad
+            outcome :iidb_maybe_outcome # A30 already_abroad and A31 going_abroad
           end
         end
       end
@@ -561,24 +459,18 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :db_already_abroad_eea_outcome,
-          :db_already_abroad_other_outcome,
-          :db_going_abroad_eea_outcome,
-          :db_going_abroad_other_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if going_abroad
             if response == 'yes'
-              :db_going_abroad_eea_outcome # A37 going_abroad
+              outcome :db_going_abroad_eea_outcome # A37 going_abroad
             else
-              :db_going_abroad_other_outcome # A36 going_abroad
+              outcome :db_going_abroad_other_outcome # A36 going_abroad
             end
           elsif already_abroad
             if response == 'yes'
-              :db_already_abroad_eea_outcome # A36 already_abroad
+              outcome :db_already_abroad_eea_outcome # A36 already_abroad
             else
-              :db_already_abroad_other_outcome # A35 already_abroad
+              outcome :db_already_abroad_other_outcome # A35 already_abroad
             end
           end
         end
@@ -589,16 +481,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_claiming_benefits_outcome,
-          :is_either_of_the_following?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :is_claiming_benefits_outcome # A43 going_abroad
+            outcome :is_claiming_benefits_outcome # A43 going_abroad
           when 'no'
-            :is_either_of_the_following? # Q34 going_abroad
+            question :is_either_of_the_following? # Q34 going_abroad
           end
         end
       end
@@ -608,16 +496,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_abroad_for_treatment?,
-          :is_any_of_the_following_apply?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :is_abroad_for_treatment? # Q35 going_abroad
+            question :is_abroad_for_treatment? # Q35 going_abroad
           when 'no'
-            :is_any_of_the_following_apply? # Q37 going_abroad
+            question :is_any_of_the_following_apply? # Q37 going_abroad
           end
         end
       end
@@ -627,16 +511,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_abroad_for_treatment_outcome,
-          :is_work_or_sick_pay?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :is_abroad_for_treatment_outcome # A44 going_abroad
+            outcome :is_abroad_for_treatment_outcome # A44 going_abroad
           when 'no'
-            :is_work_or_sick_pay? # Q36 going_abroad
+            question :is_work_or_sick_pay? # Q36 going_abroad
           end
         end
       end
@@ -646,16 +526,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_abroad_for_treatment_outcome,
-          :is_not_eligible_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :is_abroad_for_treatment_outcome # A44 going_abroad
+            outcome :is_abroad_for_treatment_outcome # A44 going_abroad
           when 'no'
-            :is_not_eligible_outcome # A45 going_abroad
+            outcome :is_not_eligible_outcome # A45 going_abroad
           end
         end
       end
@@ -665,16 +541,12 @@ def define
         option :yes
         option :no
 
-        permitted_next_nodes = [
-          :is_not_eligible_outcome,
-          :is_abroad_for_treatment_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'yes'
-            :is_not_eligible_outcome # A45 going_abroad
+            outcome :is_not_eligible_outcome # A45 going_abroad
           when 'no'
-            :is_abroad_for_treatment_outcome # A44 going_abroad
+            outcome :is_abroad_for_treatment_outcome # A44 going_abroad
           end
         end
       end
@@ -688,19 +560,14 @@ def define
 
         save_input_as :how_long_abroad_jsa
 
-        permitted_next_nodes = [
-          :jsa_less_than_a_year_medical_outcome,
-          :jsa_less_than_a_year_other_outcome,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'less_than_a_year_medical'
-            :jsa_less_than_a_year_medical_outcome # A3 going_abroad
+            outcome :jsa_less_than_a_year_medical_outcome # A3 going_abroad
           when 'less_than_a_year_other'
-            :jsa_less_than_a_year_other_outcome # A4 going_abroad
+            outcome :jsa_less_than_a_year_other_outcome # A4 going_abroad
           when 'more_than_a_year'
-            :which_country?
+            question :which_country?
           end
         end
       end
@@ -709,16 +576,12 @@ def define
         option :tax_credits_up_to_a_year
         option :tax_credits_more_than_a_year
 
-        permitted_next_nodes = [
-          :tax_credits_why_going_abroad?,
-          :tax_credits_children?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'tax_credits_up_to_a_year'
-            :tax_credits_why_going_abroad? #Q23 going_abroad and Q22 already_abroad
+            question :tax_credits_why_going_abroad? #Q23 going_abroad and Q22 already_abroad
           when 'tax_credits_more_than_a_year'
-            :tax_credits_children? # Q19 going_abroad and Q18 already_abroad
+            question :tax_credits_children? # Q19 going_abroad and Q18 already_abroad
           end
         end
       end
@@ -729,24 +592,17 @@ def define
         option :esa_under_a_year_other
         option :esa_more_than_a_year
 
-        permitted_next_nodes = [
-          :esa_already_abroad_under_a_year_medical_outcome,
-          :esa_already_abroad_under_a_year_other_outcome,
-          :esa_going_abroad_under_a_year_medical_outcome,
-          :esa_going_abroad_under_a_year_other_outcome,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if going_abroad && response == 'esa_under_a_year_medical'
-            :esa_going_abroad_under_a_year_medical_outcome # A27 going_abroad
+            outcome :esa_going_abroad_under_a_year_medical_outcome # A27 going_abroad
           elsif going_abroad && response == 'esa_under_a_year_other'
-            :esa_going_abroad_under_a_year_other_outcome # A28 going_abroad
+            outcome :esa_going_abroad_under_a_year_other_outcome # A28 going_abroad
           elsif already_abroad && response == 'esa_under_a_year_medical'
-            :esa_already_abroad_under_a_year_medical_outcome # A25 already_abroad
+            outcome :esa_already_abroad_under_a_year_medical_outcome # A25 already_abroad
           elsif already_abroad && response == 'esa_under_a_year_other'
-            :esa_already_abroad_under_a_year_other_outcome # A26 already_abroad
+            outcome :esa_already_abroad_under_a_year_other_outcome # A26 already_abroad
           else
-            :which_country?
+            question :which_country?
           end
         end
       end
@@ -756,18 +612,13 @@ def define
         option :temporary
         option :permanent
 
-        permitted_next_nodes = [
-          :db_already_abroad_temporary_outcome,
-          :db_going_abroad_temporary_outcome,
-          :which_country?
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           if response == 'permanent'
-            :which_country? # Q25
+            question :which_country? # Q25
           elsif going_abroad
-            :db_going_abroad_temporary_outcome # A35 going_abroad
+            outcome :db_going_abroad_temporary_outcome # A35 going_abroad
           else
-            :db_already_abroad_temporary_outcome # A34 already_abroad
+            outcome :db_already_abroad_temporary_outcome # A34 already_abroad
           end
         end
       end
@@ -778,19 +629,14 @@ def define
         option :is_under_a_year_other
         option :is_more_than_a_year
 
-        permitted_next_nodes = [
-          :is_under_a_year_medical_outcome,
-          :is_claiming_benefits?,
-          :is_more_than_a_year_outcome
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'is_under_a_year_medical'
-            :is_under_a_year_medical_outcome # A42 going_abroad
+            outcome :is_under_a_year_medical_outcome # A42 going_abroad
           when 'is_under_a_year_other'
-            :is_claiming_benefits? # Q33 going_abroad
+            question :is_claiming_benefits? # Q33 going_abroad
           when 'is_more_than_a_year'
-            :is_more_than_a_year_outcome # A41 going_abroad
+            outcome :is_more_than_a_year_outcome # A41 going_abroad
           end
         end
       end
diff --git a/test/data/uk-benefits-abroad-files.yml b/test/data/uk-benefits-abroad-files.yml
index 98a9bc4f85d..fc146251b5b 100644
--- a/test/data/uk-benefits-abroad-files.yml
+++ b/test/data/uk-benefits-abroad-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/uk-benefits-abroad.rb: dd2bc57e36dd66cb47a92b5cec57c5a8
+lib/smart_answer_flows/uk-benefits-abroad.rb: b4511d920af4732c8ccc9fe6330f6fec
 test/data/uk-benefits-abroad-questions-and-responses.yml: 279454ec0916c13ac09ed5a90ad58777
 test/data/uk-benefits-abroad-responses-and-expected-results.yml: dbf714c4de3ed03f81c868c354aa9c81
 lib/smart_answer_flows/uk-benefits-abroad/outcomes/_tax_credits_already_abroad_helpline.govspeak.erb: d79b1b09c2fe01c66cdda028a7679b8b

From e6878642fd8cde5a9bc5450c24c85555a4e488b9 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:37:12 +0100
Subject: [PATCH 36/44] Automatic next_node detection in vat-payment-deadlines

---
 .../vat-payment-deadlines.rb                  | 25 ++++++-------------
 test/data/vat-payment-deadlines-files.yml     |  2 +-
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/lib/smart_answer_flows/vat-payment-deadlines.rb b/lib/smart_answer_flows/vat-payment-deadlines.rb
index 30eb21bf810..2002bd41542 100644
--- a/lib/smart_answer_flows/vat-payment-deadlines.rb
+++ b/lib/smart_answer_flows/vat-payment-deadlines.rb
@@ -37,31 +37,22 @@ def define
           calculator.funds_received_by.strftime("%e %B %Y").strip
         end
 
-        permitted_next_nodes = [
-          :result_direct_debit,
-          :result_online_telephone_banking,
-          :result_online_debit_credit_card,
-          :result_bacs_direct_credit,
-          :result_bank_giro,
-          :result_chaps,
-          :result_cheque
-        ]
-        next_node(permitted: permitted_next_nodes) do |response|
+        next_node(permitted: :auto) do |response|
           case response
           when 'direct-debit'
-            :result_direct_debit
+            outcome :result_direct_debit
           when 'online-telephone-banking'
-            :result_online_telephone_banking
+            outcome :result_online_telephone_banking
           when 'online-debit-credit-card'
-            :result_online_debit_credit_card
+            outcome :result_online_debit_credit_card
           when 'bacs-direct-credit'
-            :result_bacs_direct_credit
+            outcome :result_bacs_direct_credit
           when 'bank-giro'
-            :result_bank_giro
+            outcome :result_bank_giro
           when 'chaps'
-            :result_chaps
+            outcome :result_chaps
           when 'cheque'
-            :result_cheque
+            outcome :result_cheque
           end
         end
       end
diff --git a/test/data/vat-payment-deadlines-files.yml b/test/data/vat-payment-deadlines-files.yml
index 7b36b7d14b9..5437f78377f 100644
--- a/test/data/vat-payment-deadlines-files.yml
+++ b/test/data/vat-payment-deadlines-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/vat-payment-deadlines.rb: 20c950f46ed03b57bc2b1d77e2fb16bd
+lib/smart_answer_flows/vat-payment-deadlines.rb: 3c00e5dfce33cc7e9d5ca894bb8bbe98
 test/data/vat-payment-deadlines-questions-and-responses.yml: f72f44a680cae3450cafd4f7a0f6bc15
 test/data/vat-payment-deadlines-responses-and-expected-results.yml: a28afd1561b42a1dcbba04dce5f16d3e
 lib/smart_answer_flows/vat-payment-deadlines/outcomes/result_bacs_direct_credit.govspeak.erb: 063a6e204352bdbb75a0e1edd7d2e7b3

From b95e8d84d67f16276964fff60b36f91080990a57 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:43:12 +0100
Subject: [PATCH 37/44] Automatic next_node detection in adoption-calculator

---
 .../shared_logic/adoption-calculator.rb       | 63 ++++++-------------
 .../maternity-paternity-calculator-files.yml  |  2 +-
 2 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/lib/smart_answer_flows/shared_logic/adoption-calculator.rb b/lib/smart_answer_flows/shared_logic/adoption-calculator.rb
index 3e5feacc8ca..43c95f8b660 100644
--- a/lib/smart_answer_flows/shared_logic/adoption-calculator.rb
+++ b/lib/smart_answer_flows/shared_logic/adoption-calculator.rb
@@ -3,16 +3,12 @@
   option :yes
   option :no
 
-  permitted_next_nodes = [
-    :employee_date_matched_paternity_adoption?,
-    :date_of_adoption_match?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :employee_date_matched_paternity_adoption? #QAP1
+      question :employee_date_matched_paternity_adoption? #QAP1
     when 'no'
-      :date_of_adoption_match? # QA1
+      question :date_of_adoption_match? # QA1
     end
   end
 end
@@ -62,16 +58,12 @@
   option :yes
   option :no
 
-  permitted_next_nodes = [
-    :adoption_employment_contract?,
-    :adoption_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :adoption_employment_contract?
+      question :adoption_employment_contract?
     when 'no'
-      :adoption_not_entitled_to_leave_or_pay
+      outcome :adoption_not_entitled_to_leave_or_pay
     end
   end
 end
@@ -105,15 +97,11 @@
     employee_has_contract_adoption == 'no' && response == 'no'
   end
 
-  permitted_next_nodes = [
-    :adoption_date_leave_starts?,
-    :adoption_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if no_contract_not_on_payroll
-      :adoption_not_entitled_to_leave_or_pay
+      outcome :adoption_not_entitled_to_leave_or_pay
     else
-      :adoption_date_leave_starts?
+      question :adoption_date_leave_starts?
     end
   end
 end
@@ -150,15 +138,11 @@
     employee_has_contract_adoption == 'yes' && on_payroll == 'no'
   end
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :last_normal_payday_adoption?
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if has_contract_not_on_payroll
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :last_normal_payday_adoption?
+      question :last_normal_payday_adoption?
     end
   end
 end
@@ -243,15 +227,11 @@
     calculator.average_weekly_earnings < calculator.lower_earning_limit
   end
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :how_do_you_want_the_sap_calculated?
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if average_weekly_earnings_under_lower_earning_limit
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :how_do_you_want_the_sap_calculated?
+      question :how_do_you_want_the_sap_calculated?
     end
   end
 end
@@ -263,18 +243,13 @@
 
   save_input_as :sap_calculation_method
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :monthly_pay_paternity?,
-    :next_pay_day_paternity?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response == 'weekly_starting'
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     elsif pay_pattern == 'monthly'
-      :monthly_pay_paternity?
+      question :monthly_pay_paternity?
     else
-      :next_pay_day_paternity?
+      question :next_pay_day_paternity?
     end
   end
 end
diff --git a/test/data/maternity-paternity-calculator-files.yml b/test/data/maternity-paternity-calculator-files.yml
index 685b311857f..e1dd278e6be 100644
--- a/test/data/maternity-paternity-calculator-files.yml
+++ b/test/data/maternity-paternity-calculator-files.yml
@@ -70,7 +70,7 @@ lib/smart_answer_flows/maternity-paternity-calculator/questions/what_type_of_lea
 lib/smart_answer_flows/maternity-paternity-calculator/questions/when_in_the_month_is_the_employee_paid.govspeak.erb: d540503a4470d20b26ceb4fd5a84a3f4
 lib/smart_answer_flows/maternity-paternity-calculator/questions/when_is_your_employees_next_pay_day.govspeak.erb: a74aad333d92213910367be1ecee9e80
 lib/smart_answer_flows/maternity-paternity-calculator/questions/which_week_in_month_is_the_employee_paid.govspeak.erb: 19fef5ffcbb85e74f88dd24ce3ccf4c0
-lib/smart_answer_flows/shared_logic/adoption-calculator.rb: 74d75b8b3fd2a62ae177dffce0271b1f
+lib/smart_answer_flows/shared_logic/adoption-calculator.rb: 1bcb90801161a4366b0551acd022d4d9
 lib/smart_answer_flows/shared_logic/maternity-calculator.rb: 93d151262f844f606f21d711aef31ba7
 lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 4db5c4bc2f2e96f52bbdc41d7aa850a5
 lib/smart_answer/calculators/maternity_paternity_calculator.rb: 24de99189c23e9a7cc048871a817bb3c

From 80bc4d31f324e64d9ffbd2fcdc2190dfa4f604fe Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 13:51:27 +0100
Subject: [PATCH 38/44] Automatic next_node detection in maternity-calculator

---
 .../shared_logic/maternity-calculator.rb      | 49 ++++++-------------
 .../maternity-paternity-calculator-files.yml  |  2 +-
 2 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/lib/smart_answer_flows/shared_logic/maternity-calculator.rb b/lib/smart_answer_flows/shared_logic/maternity-calculator.rb
index f8bfca8435b..450b7a0e8e0 100644
--- a/lib/smart_answer_flows/shared_logic/maternity-calculator.rb
+++ b/lib/smart_answer_flows/shared_logic/maternity-calculator.rb
@@ -74,16 +74,12 @@
     response == 'no' ? :not_worked_long_enough : nil
   end
 
-  permitted_next_nodes = [
-    :is_the_employee_on_your_payroll?,
-    :maternity_leave_and_pay_result
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :is_the_employee_on_your_payroll?
+      question :is_the_employee_on_your_payroll?
     when 'no'
-      :maternity_leave_and_pay_result
+      outcome :maternity_leave_and_pay_result
     end
   end
 end
@@ -105,16 +101,12 @@
     calculator.format_date_day to_saturday
   end
 
-  permitted_next_nodes = [
-    :last_normal_payday?,
-    :maternity_leave_and_pay_result
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :last_normal_payday? # NOTE: goes to shared questions
+      question :last_normal_payday? # NOTE: goes to shared questions
     when 'no'
-      :maternity_leave_and_pay_result
+      outcome :maternity_leave_and_pay_result
     end
   end
 end
@@ -189,20 +181,15 @@
 
   save_input_as :smp_calculation_method
 
-  permitted_next_nodes = [
-    :maternity_leave_and_pay_result,
-    :when_in_the_month_is_the_employee_paid?,
-    :when_is_your_employees_next_pay_day?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response == 'usual_paydates'
       if pay_pattern == 'monthly'
-        :when_in_the_month_is_the_employee_paid?
+        question :when_in_the_month_is_the_employee_paid?
       else
-        :when_is_your_employees_next_pay_day?
+        question :when_is_your_employees_next_pay_day?
       end
     else
-      :maternity_leave_and_pay_result
+      outcome :maternity_leave_and_pay_result
     end
   end
 end
@@ -227,22 +214,16 @@
 
   save_input_as :monthly_pay_method
 
-  permitted_next_nodes = [
-    :maternity_leave_and_pay_result,
-    :what_specific_date_each_month_is_the_employee_paid?,
-    :what_days_does_the_employee_work?,
-    :what_particular_day_of_the_month_is_the_employee_paid?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'first_day_of_the_month', 'last_day_of_the_month'
-      :maternity_leave_and_pay_result
+      outcome :maternity_leave_and_pay_result
     when 'specific_date_each_month'
-      :what_specific_date_each_month_is_the_employee_paid?
+      question :what_specific_date_each_month_is_the_employee_paid?
     when 'last_working_day_of_the_month'
-      :what_days_does_the_employee_work?
+      question :what_days_does_the_employee_work?
     when 'a_certain_week_day_each_month'
-      :what_particular_day_of_the_month_is_the_employee_paid?
+      question :what_particular_day_of_the_month_is_the_employee_paid?
     end
   end
 end
diff --git a/test/data/maternity-paternity-calculator-files.yml b/test/data/maternity-paternity-calculator-files.yml
index e1dd278e6be..daaf161cc87 100644
--- a/test/data/maternity-paternity-calculator-files.yml
+++ b/test/data/maternity-paternity-calculator-files.yml
@@ -71,7 +71,7 @@ lib/smart_answer_flows/maternity-paternity-calculator/questions/when_in_the_mont
 lib/smart_answer_flows/maternity-paternity-calculator/questions/when_is_your_employees_next_pay_day.govspeak.erb: a74aad333d92213910367be1ecee9e80
 lib/smart_answer_flows/maternity-paternity-calculator/questions/which_week_in_month_is_the_employee_paid.govspeak.erb: 19fef5ffcbb85e74f88dd24ce3ccf4c0
 lib/smart_answer_flows/shared_logic/adoption-calculator.rb: 1bcb90801161a4366b0551acd022d4d9
-lib/smart_answer_flows/shared_logic/maternity-calculator.rb: 93d151262f844f606f21d711aef31ba7
+lib/smart_answer_flows/shared_logic/maternity-calculator.rb: aa35d8b3bc3329953ca8ed056d20148e
 lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 4db5c4bc2f2e96f52bbdc41d7aa850a5
 lib/smart_answer/calculators/maternity_paternity_calculator.rb: 24de99189c23e9a7cc048871a817bb3c
 lib/data/rates/maternity_paternity_birth.yml: 3eef956f1020576a9343647fec34dd01

From a1bf0bd19921688e45ad11d3ada87f89bc9e4bb8 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 14:02:42 +0100
Subject: [PATCH 39/44] Automatic next_node detection in minimum_wage

---
 .../shared_logic/minimum_wage.rb              | 168 ++++++------------
 test/data/am-i-getting-minimum-wage-files.yml |   2 +-
 ...inimum-wage-calculator-employers-files.yml |   2 +-
 3 files changed, 52 insertions(+), 120 deletions(-)

diff --git a/lib/smart_answer_flows/shared_logic/minimum_wage.rb b/lib/smart_answer_flows/shared_logic/minimum_wage.rb
index c23f324142b..3d1a35d9d75 100644
--- a/lib/smart_answer_flows/shared_logic/minimum_wage.rb
+++ b/lib/smart_answer_flows/shared_logic/minimum_wage.rb
@@ -8,11 +8,9 @@
   option "2009-10-01"
   option "2008-10-01"
 
-  permitted_next_nodes = [:were_you_an_apprentice?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.date = Date.parse(response)
-    :were_you_an_apprentice?
+    question :were_you_an_apprentice?
   end
 end
 
@@ -23,19 +21,14 @@
   option "apprentice_over_19_first_year"
   option "apprentice_over_19_second_year_onwards"
 
-  permitted_next_nodes = [
-    :how_old_are_you?,
-    :how_often_do_you_get_paid?
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'not_an_apprentice', 'apprentice_over_19_second_year_onwards'
       calculator.is_apprentice = false
-      :how_old_are_you?
+      question :how_old_are_you?
     when 'apprentice_under_19', 'apprentice_over_19_first_year'
       calculator.is_apprentice = true
-      :how_often_do_you_get_paid?
+      question :how_often_do_you_get_paid?
     end
   end
 end
@@ -46,23 +39,17 @@
   option "apprentice_under_19"
   option "apprentice_over_19"
 
-  permitted_next_nodes = [
-    :how_old_were_you?,
-    :how_often_did_you_get_paid?,
-    :does_not_apply_to_historical_apprentices
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when "no"
       calculator.is_apprentice = false
-      :how_old_were_you?
+      question :how_old_were_you?
     else
       calculator.is_apprentice = true
       if calculator.apprentice_eligible_for_minimum_wage?
-        :how_often_did_you_get_paid?
+        question :how_often_did_you_get_paid?
       else
-        :does_not_apply_to_historical_apprentices
+        outcome :does_not_apply_to_historical_apprentices
       end
     end
   end
@@ -74,17 +61,12 @@
     calculator.valid_age?(response)
   end
 
-  permitted_next_nodes = [
-    :under_school_leaving_age_past,
-    :how_often_did_you_get_paid?
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.age = response
     if calculator.under_school_leaving_age?
-      :under_school_leaving_age_past
+      outcome :under_school_leaving_age_past
     else
-      :how_often_did_you_get_paid?
+      question :how_often_did_you_get_paid?
     end
   end
 end
@@ -95,11 +77,9 @@
     calculator.valid_pay_frequency?(response)
   end
 
-  permitted_next_nodes = [:how_many_hours_do_you_work?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.pay_frequency = response
-    :how_many_hours_do_you_work?
+    question :how_many_hours_do_you_work?
   end
 end
 
@@ -109,11 +89,9 @@
     calculator.valid_pay_frequency?(response)
   end
 
-  permitted_next_nodes = [:how_many_hours_did_you_work?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.pay_frequency = response
-    :how_many_hours_did_you_work?
+    question :how_many_hours_did_you_work?
   end
 end
 
@@ -123,11 +101,9 @@
     calculator.valid_hours_worked?(response)
   end
 
-  permitted_next_nodes = [:how_much_are_you_paid_during_pay_period?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.basic_hours = response
-    :how_much_are_you_paid_during_pay_period?
+    question :how_much_are_you_paid_during_pay_period?
   end
 end
 
@@ -137,31 +113,25 @@
     calculator.valid_hours_worked?(response)
   end
 
-  permitted_next_nodes = [:how_much_were_you_paid_during_pay_period?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.basic_hours = response
-    :how_much_were_you_paid_during_pay_period?
+    question :how_much_were_you_paid_during_pay_period?
   end
 end
 
 # Q6
 money_question :how_much_are_you_paid_during_pay_period? do
-  permitted_next_nodes = [:how_many_hours_overtime_do_you_work?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.basic_pay = Float(response)
-    :how_many_hours_overtime_do_you_work?
+    question :how_many_hours_overtime_do_you_work?
   end
 end
 
 # Q6 Past
 money_question :how_much_were_you_paid_during_pay_period? do
-  permitted_next_nodes = [:how_many_hours_overtime_did_you_work?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.basic_pay = Float(response)
-    :how_many_hours_overtime_did_you_work?
+    question :how_many_hours_overtime_did_you_work?
   end
 end
 
@@ -171,17 +141,12 @@
     calculator.valid_overtime_hours_worked?(response)
   end
 
-  permitted_next_nodes = [
-    :what_is_overtime_pay_per_hour?,
-    :is_provided_with_accommodation?
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.overtime_hours = response
     if calculator.any_overtime_hours_worked?
-      :what_is_overtime_pay_per_hour?
+      question :what_is_overtime_pay_per_hour?
     else
-      :is_provided_with_accommodation?
+      question :is_provided_with_accommodation?
     end
   end
 end
@@ -192,38 +157,29 @@
     calculator.valid_overtime_hours_worked?(response)
   end
 
-  permitted_next_nodes = [
-    :what_was_overtime_pay_per_hour?,
-    :was_provided_with_accommodation?
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.overtime_hours = response
     if calculator.any_overtime_hours_worked?
-      :what_was_overtime_pay_per_hour?
+      question :what_was_overtime_pay_per_hour?
     else
-      :was_provided_with_accommodation?
+      question :was_provided_with_accommodation?
     end
   end
 end
 
 # Q8
 money_question :what_is_overtime_pay_per_hour? do
-  permitted_next_nodes = [:is_provided_with_accommodation?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.overtime_hourly_rate = Float(response)
-    :is_provided_with_accommodation?
+    question :is_provided_with_accommodation?
   end
 end
 
 # Q8 Past
 money_question :what_was_overtime_pay_per_hour? do
-  permitted_next_nodes = [:was_provided_with_accommodation?]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.overtime_hourly_rate = Float(response)
-    :was_provided_with_accommodation?
+    question :was_provided_with_accommodation?
   end
 end
 
@@ -233,24 +189,17 @@
   option "yes_free"
   option "yes_charged"
 
-  permitted_next_nodes = [
-    :current_accommodation_usage?,
-    :current_accommodation_charge?,
-    :current_payment_above,
-    :current_payment_below
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when "yes_free"
-      :current_accommodation_usage?
+      question :current_accommodation_usage?
     when "yes_charged"
-      :current_accommodation_charge?
+      question :current_accommodation_charge?
     else
       if calculator.minimum_wage_or_above?
-        :current_payment_above
+        outcome :current_payment_above
       else
-        :current_payment_below
+        outcome :current_payment_below
       end
     end
   end
@@ -262,24 +211,17 @@
   option "yes_free"
   option "yes_charged"
 
-  permitted_next_nodes = [
-    :past_accommodation_usage?,
-    :past_accommodation_charge?,
-    :past_payment_above,
-    :past_payment_below
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when "yes_free"
-      :past_accommodation_usage?
+      question :past_accommodation_usage?
     when "yes_charged"
-      :past_accommodation_charge?
+      question :past_accommodation_charge?
     else
       if calculator.minimum_wage_or_above?
-        :past_payment_above
+        outcome :past_payment_above
       else
-        :past_payment_below
+        outcome :past_payment_below
       end
     end
   end
@@ -313,17 +255,12 @@
     calculator.valid_accommodation_usage?(response)
   end
 
-  permitted_next_nodes = [
-    :current_payment_above,
-    :current_payment_below
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.accommodation_adjustment(accommodation_charge, response)
     if calculator.minimum_wage_or_above?
-      :current_payment_above
+      outcome :current_payment_above
     else
-      :current_payment_below
+      outcome :current_payment_below
     end
   end
 end
@@ -334,17 +271,12 @@
     calculator.valid_accommodation_usage?(response)
   end
 
-  permitted_next_nodes = [
-    :past_payment_above,
-    :past_payment_below
-  ]
-
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     calculator.accommodation_adjustment(accommodation_charge, response)
     if calculator.historically_receiving_minimum_wage?
-      :past_payment_above
+      outcome :past_payment_above
     else
-      :past_payment_below
+      outcome :past_payment_below
     end
   end
 end
diff --git a/test/data/am-i-getting-minimum-wage-files.yml b/test/data/am-i-getting-minimum-wage-files.yml
index 72f6eb31b26..00810d81c39 100644
--- a/test/data/am-i-getting-minimum-wage-files.yml
+++ b/test/data/am-i-getting-minimum-wage-files.yml
@@ -35,6 +35,6 @@ lib/smart_answer_flows/am-i-getting-minimum-wage/questions/what_was_overtime_pay
 lib/smart_answer_flows/am-i-getting-minimum-wage/questions/what_would_you_like_to_check.govspeak.erb: c3ae31e57b1f5d78a30c08ed6e22f245
 lib/smart_answer_flows/am-i-getting-minimum-wage/questions/will_you_be_a_first_year_apprentice.govspeak.erb: 524767101e41ecf9a65e030adb1141f9
 lib/smart_answer_flows/shared/minimum_wage/_acas_information.govspeak.erb: 582cdf982fa5619072ddd883bf4c1555
-lib/smart_answer_flows/shared_logic/minimum_wage.rb: 331cf52d0be5f0128e71b4acf2903bc6
+lib/smart_answer_flows/shared_logic/minimum_wage.rb: ac1f1dcba5ecdd93eb2bc9c117455aab
 lib/smart_answer/calculators/minimum_wage_calculator.rb: 721f27ae7e3366e4227688213590e00b
 lib/data/minimum_wage_data.yml: ff0204584fe4e0672370fda487121915
diff --git a/test/data/minimum-wage-calculator-employers-files.yml b/test/data/minimum-wage-calculator-employers-files.yml
index e8657813538..8c1d47d4b6e 100644
--- a/test/data/minimum-wage-calculator-employers-files.yml
+++ b/test/data/minimum-wage-calculator-employers-files.yml
@@ -33,6 +33,6 @@ lib/smart_answer_flows/minimum-wage-calculator-employers/questions/what_is_overt
 lib/smart_answer_flows/minimum-wage-calculator-employers/questions/what_was_overtime_pay_per_hour.govspeak.erb: 82a7b7b692aac807fdd73c4f5b6aea22
 lib/smart_answer_flows/minimum-wage-calculator-employers/questions/what_would_you_like_to_check.govspeak.erb: a9fce44b7f15b6f72eee6df0464f7bbf
 lib/smart_answer_flows/shared/minimum_wage/_acas_information.govspeak.erb: 582cdf982fa5619072ddd883bf4c1555
-lib/smart_answer_flows/shared_logic/minimum_wage.rb: 331cf52d0be5f0128e71b4acf2903bc6
+lib/smart_answer_flows/shared_logic/minimum_wage.rb: ac1f1dcba5ecdd93eb2bc9c117455aab
 lib/smart_answer/calculators/minimum_wage_calculator.rb: 721f27ae7e3366e4227688213590e00b
 lib/data/minimum_wage_data.yml: ff0204584fe4e0672370fda487121915

From 6c4951e1b549c5b51cc5d88e90ed934561db0edc Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 14:09:51 +0100
Subject: [PATCH 40/44] Automatic next_node detection in paternity-calculator

---
 .../shared_logic/paternity-calculator.rb      | 145 ++++++------------
 .../maternity-paternity-calculator-files.yml  |   2 +-
 2 files changed, 45 insertions(+), 102 deletions(-)

diff --git a/lib/smart_answer_flows/shared_logic/paternity-calculator.rb b/lib/smart_answer_flows/shared_logic/paternity-calculator.rb
index 4eb1e9239a4..fc4508c5bfe 100644
--- a/lib/smart_answer_flows/shared_logic/paternity-calculator.rb
+++ b/lib/smart_answer_flows/shared_logic/paternity-calculator.rb
@@ -5,16 +5,12 @@
   option :yes
   option :no
 
-  permitted_next_nodes = [
-    :employee_date_matched_paternity_adoption?,
-    :baby_due_date_paternity?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :employee_date_matched_paternity_adoption?
+      question :employee_date_matched_paternity_adoption?
     when 'no'
-      :baby_due_date_paternity?
+      question :baby_due_date_paternity?
     end
   end
 end
@@ -110,16 +106,12 @@
     calculator.notice_of_leave_deadline
   end
 
-  permitted_next_nodes = [
-    :employee_work_before_employment_start?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :employee_work_before_employment_start?
+      question :employee_work_before_employment_start?
     when 'no'
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     end
   end
 end
@@ -142,16 +134,12 @@
     calculator.qualifying_week.first
   end
 
-  permitted_next_nodes = [
-    :employee_work_before_employment_start?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :employee_work_before_employment_start? # Combined flow
+      question :employee_work_before_employment_start? # Combined flow
     when 'no'
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     end
   end
 end
@@ -162,16 +150,12 @@
   option :no
   save_input_as :paternity_employment_start ## Needed only in outcome
 
-  permitted_next_nodes = [
-    :employee_has_contract_paternity?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     case response
     when 'yes'
-      :employee_has_contract_paternity?
+      question :employee_has_contract_paternity?
     when 'no'
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     end
   end
 end
@@ -217,18 +201,13 @@
     paternity_adoption ? ap_adoption_date_formatted : date_of_birth
   end
 
-  permitted_next_nodes = [
-    :employee_start_paternity?,
-    :employee_still_employed_on_birth_date?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response == 'yes'
-      :employee_still_employed_on_birth_date?
+      question :employee_still_employed_on_birth_date?
     elsif has_contract == 'no'
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     else
-      :employee_start_paternity?
+      question :employee_start_paternity?
     end
   end
 end
@@ -239,15 +218,11 @@
   option :no
   save_input_as :employed_dob
 
-  permitted_next_nodes = [
-    :employee_start_paternity?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if has_contract == 'no' && response == 'no'
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     else
-      :employee_start_paternity?
+      question :employee_start_paternity?
     end
   end
 end
@@ -287,15 +262,11 @@
     calculator.pay_end_date
   end
 
-  permitted_next_nodes = [
-    :last_normal_payday_paternity?,
-    :paternity_not_entitled_to_leave_or_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if has_contract == 'yes' && (on_payroll == 'no' || employed_dob == 'no')
-      :paternity_not_entitled_to_leave_or_pay
+      outcome :paternity_not_entitled_to_leave_or_pay
     else
-      :last_normal_payday_paternity?
+      question :last_normal_payday_paternity?
     end
   end
 end
@@ -370,15 +341,11 @@
     calculator.average_weekly_earnings < calculator.lower_earning_limit
   end
 
-  permitted_next_nodes = [
-    :how_do_you_want_the_spp_calculated?,
-    :paternity_leave_and_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if average_weekly_earnings_under_lower_earning_limit
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     else
-      :how_do_you_want_the_spp_calculated?
+      question :how_do_you_want_the_spp_calculated?
     end
   end
 end
@@ -390,18 +357,13 @@
 
   save_input_as :spp_calculation_method
 
-  permitted_next_nodes = [
-    :monthly_pay_paternity?,
-    :next_pay_day_paternity?,
-    :paternity_leave_and_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response == 'weekly_starting'
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     elsif pay_pattern == 'monthly'
-      :monthly_pay_paternity?
+      question :monthly_pay_paternity?
     else
-      :next_pay_day_paternity?
+      question :next_pay_day_paternity?
     end
   end
 end
@@ -429,24 +391,17 @@
 
   save_input_as :monthly_pay_method
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :day_of_the_month_paternity?,
-    :days_of_the_week_paternity?,
-    :paternity_leave_and_pay,
-    :specific_date_each_month_paternity?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response == 'specific_date_each_month'
-      :specific_date_each_month_paternity?
+      question :specific_date_each_month_paternity?
     elsif response == 'last_working_day_of_the_month'
-      :days_of_the_week_paternity?
+      question :days_of_the_week_paternity?
     elsif response == 'a_certain_week_day_each_month'
-      :day_of_the_month_paternity?
+      question :day_of_the_month_paternity?
     elsif leave_type == 'adoption'
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     end
   end
 end
@@ -460,15 +415,11 @@
     calculator.pay_day_in_month = day
   end
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :paternity_leave_and_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if leave_type == 'adoption'
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     end
   end
 end
@@ -482,15 +433,11 @@
     calculator.pay_day_in_week = response.split(",").sort.last.to_i
   end
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :paternity_leave_and_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if leave_type == 'adoption'
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     end
   end
 end
@@ -525,15 +472,11 @@
     calculator.pay_week_in_month = response
   end
 
-  permitted_next_nodes = [
-    :adoption_leave_and_pay,
-    :paternity_leave_and_pay
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if leave_type == 'adoption'
-      :adoption_leave_and_pay
+      outcome :adoption_leave_and_pay
     else
-      :paternity_leave_and_pay
+      outcome :paternity_leave_and_pay
     end
   end
 end
diff --git a/test/data/maternity-paternity-calculator-files.yml b/test/data/maternity-paternity-calculator-files.yml
index daaf161cc87..29a0100ec93 100644
--- a/test/data/maternity-paternity-calculator-files.yml
+++ b/test/data/maternity-paternity-calculator-files.yml
@@ -72,7 +72,7 @@ lib/smart_answer_flows/maternity-paternity-calculator/questions/when_is_your_emp
 lib/smart_answer_flows/maternity-paternity-calculator/questions/which_week_in_month_is_the_employee_paid.govspeak.erb: 19fef5ffcbb85e74f88dd24ce3ccf4c0
 lib/smart_answer_flows/shared_logic/adoption-calculator.rb: 1bcb90801161a4366b0551acd022d4d9
 lib/smart_answer_flows/shared_logic/maternity-calculator.rb: aa35d8b3bc3329953ca8ed056d20148e
-lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 4db5c4bc2f2e96f52bbdc41d7aa850a5
+lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 806540b08a786a367252f34165821ce9
 lib/smart_answer/calculators/maternity_paternity_calculator.rb: 24de99189c23e9a7cc048871a817bb3c
 lib/data/rates/maternity_paternity_birth.yml: 3eef956f1020576a9343647fec34dd01
 lib/data/rates/maternity_paternity_adoption.yml: 453c4d90b6fd9ffe1556782665f313fc

From b9c3837dbd032940d724adaee64f91c24c2aace6 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 14:15:31 +0100
Subject: [PATCH 41/44] Automatic next_node detection in redundancy_pay

---
 .../shared_logic/redundancy_pay.rb            | 20 ++++++-------------
 ...alculate-employee-redundancy-pay-files.yml |  2 +-
 .../calculate-your-redundancy-pay-files.yml   |  2 +-
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/lib/smart_answer_flows/shared_logic/redundancy_pay.rb b/lib/smart_answer_flows/shared_logic/redundancy_pay.rb
index 478331d1aa8..24bf6d730b7 100644
--- a/lib/smart_answer_flows/shared_logic/redundancy_pay.rb
+++ b/lib/smart_answer_flows/shared_logic/redundancy_pay.rb
@@ -49,15 +49,11 @@
     raise InvalidResponse if ye.to_i > years_available
     ye
   end
-  permitted_next_nodes = [
-    :done_no_statutory,
-    :weekly_pay_before_tax?
-  ]
-  next_node(permitted: permitted_next_nodes) do |response|
+  next_node(permitted: :auto) do |response|
     if response.floor < 2
-      :done_no_statutory
+      outcome :done_no_statutory
     else
-      :weekly_pay_before_tax?
+      question :weekly_pay_before_tax?
     end
   end
 end
@@ -83,15 +79,11 @@
     calculator.number_of_weeks_entitlement
   end
 
-  permitted_next_nodes = [
-    :done_no_statutory,
-    :done
-  ]
-  next_node(permitted: permitted_next_nodes) do
+  next_node(permitted: :auto) do
     if years_employed < 2
-      :done_no_statutory
+      outcome :done_no_statutory
     else
-      :done
+      outcome :done
     end
   end
 end
diff --git a/test/data/calculate-employee-redundancy-pay-files.yml b/test/data/calculate-employee-redundancy-pay-files.yml
index 24f5bcb8464..723c5b293ff 100644
--- a/test/data/calculate-employee-redundancy-pay-files.yml
+++ b/test/data/calculate-employee-redundancy-pay-files.yml
@@ -9,7 +9,7 @@ lib/smart_answer_flows/calculate-employee-redundancy-pay/questions/age_of_employ
 lib/smart_answer_flows/calculate-employee-redundancy-pay/questions/date_of_redundancy.govspeak.erb: e6ba7dfca27ad55335fb2cd7dda62d5f
 lib/smart_answer_flows/calculate-employee-redundancy-pay/questions/weekly_pay_before_tax.govspeak.erb: 805f2283eecf730779d648b2998db59f
 lib/smart_answer_flows/calculate-employee-redundancy-pay/questions/years_employed.govspeak.erb: 6840413403d9331d79e3b60f04d244a9
-lib/smart_answer_flows/shared_logic/redundancy_pay.rb: 2e1a5aeacda3efca59b18efecb256e58
+lib/smart_answer_flows/shared_logic/redundancy_pay.rb: deefec90f0cf079b542502a538c29270
 lib/smart_answer/calculators/redundancy_calculator.rb: 6f97d315c840f829670f64e2fabce6dd
 lib/data/rates/redundancy_pay.yml: 270b43298e223b28ba7ad3f81f5e0a08
 lib/data/rates/redundancy_pay_northern_ireland.yml: 01a56e2760328e0213318050689f2556
diff --git a/test/data/calculate-your-redundancy-pay-files.yml b/test/data/calculate-your-redundancy-pay-files.yml
index 25a4a035639..9f158fa93a9 100644
--- a/test/data/calculate-your-redundancy-pay-files.yml
+++ b/test/data/calculate-your-redundancy-pay-files.yml
@@ -9,7 +9,7 @@ lib/smart_answer_flows/calculate-your-redundancy-pay/questions/age_of_employee.g
 lib/smart_answer_flows/calculate-your-redundancy-pay/questions/date_of_redundancy.govspeak.erb: bdb2975cce5bd91c754ac13fad1af4b8
 lib/smart_answer_flows/calculate-your-redundancy-pay/questions/weekly_pay_before_tax.govspeak.erb: 9662fd7b09d3722850ede311bf27b844
 lib/smart_answer_flows/calculate-your-redundancy-pay/questions/years_employed.govspeak.erb: 6bf4ef75048732fab207104b21cdc6e6
-lib/smart_answer_flows/shared_logic/redundancy_pay.rb: 2e1a5aeacda3efca59b18efecb256e58
+lib/smart_answer_flows/shared_logic/redundancy_pay.rb: deefec90f0cf079b542502a538c29270
 lib/smart_answer/calculators/redundancy_calculator.rb: 6f97d315c840f829670f64e2fabce6dd
 lib/data/rates/redundancy_pay.yml: 270b43298e223b28ba7ad3f81f5e0a08
 lib/data/rates/redundancy_pay_northern_ireland.yml: 01a56e2760328e0213318050689f2556

From bbb14d14cde758db3b5c04537689b70dd12fa5bf Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 16:55:39 +0100
Subject: [PATCH 42/44] Remove permitted next node YAML - no longer needed

I ran the following command again:

    $ rails r script/generate-permitted-next-nodes-for-all-flows.rb

And the generated YAML was identical to the original version generated before
all the flows were changed to use the mechanism to automatically detect
permitted next nodes. So this file has served its purpose and can be removed.
---
 test/data/permitted-next-nodes.yml | 1557 ----------------------------
 1 file changed, 1557 deletions(-)
 delete mode 100644 test/data/permitted-next-nodes.yml

diff --git a/test/data/permitted-next-nodes.yml b/test/data/permitted-next-nodes.yml
deleted file mode 100644
index 9c35dad844e..00000000000
--- a/test/data/permitted-next-nodes.yml
+++ /dev/null
@@ -1,1557 +0,0 @@
----
-additional-commodity-code:
-  :how_much_milk_fat?:
-  - :commodity_code_result
-  - :how_much_milk_protein_ab?
-  - :how_much_milk_protein_c?
-  - :how_much_milk_protein_d?
-  - :how_much_milk_protein_ef?
-  - :how_much_milk_protein_gh?
-  :how_much_milk_protein_ab?:
-  - :commodity_code_result
-  :how_much_milk_protein_c?:
-  - :commodity_code_result
-  :how_much_milk_protein_d?:
-  - :commodity_code_result
-  :how_much_milk_protein_ef?:
-  - :commodity_code_result
-  :how_much_milk_protein_gh?:
-  - :commodity_code_result
-  :how_much_starch_glucose?:
-  - :how_much_sucrose_1?
-  - :how_much_sucrose_2?
-  - :how_much_sucrose_3?
-  - :how_much_sucrose_4?
-  :how_much_sucrose_1?:
-  - :how_much_milk_fat?
-  :how_much_sucrose_2?:
-  - :how_much_milk_fat?
-  :how_much_sucrose_3?:
-  - :how_much_milk_fat?
-  :how_much_sucrose_4?:
-  - :how_much_milk_fat?
-am-i-getting-minimum-wage:
-  :are_you_an_apprentice?:
-  - :how_often_do_you_get_paid?
-  - :how_old_are_you?
-  :current_accommodation_charge?:
-  - :current_accommodation_usage?
-  :current_accommodation_usage?:
-  - :current_payment_above
-  - :current_payment_below
-  :how_many_hours_did_you_work?:
-  - :how_much_were_you_paid_during_pay_period?
-  :how_many_hours_do_you_work?:
-  - :how_much_are_you_paid_during_pay_period?
-  :how_many_hours_overtime_did_you_work?:
-  - :was_provided_with_accommodation?
-  - :what_was_overtime_pay_per_hour?
-  :how_many_hours_overtime_do_you_work?:
-  - :is_provided_with_accommodation?
-  - :what_is_overtime_pay_per_hour?
-  :how_much_are_you_paid_during_pay_period?:
-  - :how_many_hours_overtime_do_you_work?
-  :how_much_were_you_paid_during_pay_period?:
-  - :how_many_hours_overtime_did_you_work?
-  :how_often_did_you_get_paid?:
-  - :how_many_hours_did_you_work?
-  :how_often_do_you_get_paid?:
-  - :how_many_hours_do_you_work?
-  :how_old_are_you?:
-  - :how_often_do_you_get_paid?
-  - :under_school_leaving_age
-  :how_old_were_you?:
-  - :how_often_did_you_get_paid?
-  - :under_school_leaving_age_past
-  :is_provided_with_accommodation?:
-  - :current_accommodation_charge?
-  - :current_accommodation_usage?
-  - :current_payment_above
-  - :current_payment_below
-  :past_accommodation_charge?:
-  - :past_accommodation_usage?
-  :past_accommodation_usage?:
-  - :past_payment_above
-  - :past_payment_below
-  :past_payment_date?:
-  - :were_you_an_apprentice?
-  :was_provided_with_accommodation?:
-  - :past_accommodation_charge?
-  - :past_accommodation_usage?
-  - :past_payment_above
-  - :past_payment_below
-  :were_you_an_apprentice?:
-  - :does_not_apply_to_historical_apprentices
-  - :how_often_did_you_get_paid?
-  - :how_old_were_you?
-  :what_is_overtime_pay_per_hour?:
-  - :is_provided_with_accommodation?
-  :what_was_overtime_pay_per_hour?:
-  - :was_provided_with_accommodation?
-  :what_would_you_like_to_check?:
-  - :are_you_an_apprentice?
-  - :past_payment_date?
-  - :will_you_be_a_first_year_apprentice?
-  :will_you_be_a_first_year_apprentice?:
-  - :does_not_apply_to_first_year_apprentices
-  - :how_old_are_you?
-benefit-cap-calculator:
-  :bereavement_amount?:
-  - :carers_amount?
-  - :child_benefit_amount?
-  - :child_tax_amount?
-  - :esa_amount?
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :carers_amount?:
-  - :child_benefit_amount?
-  - :child_tax_amount?
-  - :esa_amount?
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :child_benefit_amount?:
-  - :child_tax_amount?
-  - :esa_amount?
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :child_tax_amount?:
-  - :esa_amount?
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :esa_amount?:
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :guardian_amount?:
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :housing_benefit_amount?:
-  - :single_couple_lone_parent?
-  :incapacity_amount?:
-  - :housing_benefit_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :income_support_amount?:
-  - :housing_benefit_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :jsa_amount?:
-  - :housing_benefit_amount?
-  - :maternity_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :maternity_amount?:
-  - :housing_benefit_amount?
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :receive_housing_benefit?:
-  - :outcome_not_affected_no_housing_benefit
-  - :working_tax_credit?
-  :receiving_exemption_benefits?:
-  - :outcome_not_affected_exemptions
-  - :receiving_non_exemption_benefits?
-  :receiving_non_exemption_benefits?:
-  - :bereavement_amount?
-  - :carers_amount?
-  - :child_benefit_amount?
-  - :child_tax_amount?
-  - :esa_amount?
-  - :guardian_amount?
-  - :housing_benefit_amount?
-  - :incapacity_amount?
-  - :income_support_amount?
-  - :jsa_amount?
-  - :maternity_amount?
-  - :outcome_not_affected
-  - :sda_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :sda_amount?:
-  - :housing_benefit_amount?
-  - :single_couple_lone_parent?
-  - :widow_pension_amount?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :single_couple_lone_parent?:
-  - :outcome_affected_greater_than_cap
-  - :outcome_not_affected_less_than_cap
-  :widow_pension_amount?:
-  - :housing_benefit_amount?
-  - :single_couple_lone_parent?
-  - :widowed_mother_amount?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :widowed_mother_amount?:
-  - :housing_benefit_amount?
-  - :single_couple_lone_parent?
-  - :widowed_parent_amount?
-  - :widows_aged_amount?
-  :widowed_parent_amount?:
-  - :housing_benefit_amount?
-  - :single_couple_lone_parent?
-  - :widows_aged_amount?
-  :widows_aged_amount?:
-  - :housing_benefit_amount?
-  - :single_couple_lone_parent?
-  :working_tax_credit?:
-  - :outcome_not_affected_exemptions
-  - :receiving_exemption_benefits?
-calculate-agricultural-holiday-entitlement:
-  :how_many_days_per_week?:
-  - :worked_for_same_employer?
-  :how_many_total_days?:
-  - :worked_for_same_employer?
-  :how_many_weeks_at_current_employer?:
-  - :done
-  :what_date_does_holiday_start?:
-  - :how_many_total_days?
-  :work_the_same_number_of_days_each_week?:
-  - :how_many_days_per_week?
-  - :what_date_does_holiday_start?
-  :worked_for_same_employer?:
-  - :done
-  - :how_many_weeks_at_current_employer?
-calculate-employee-redundancy-pay:
-  :age_of_employee?:
-  - :years_employed?
-  :date_of_redundancy?:
-  - :age_of_employee?
-  :weekly_pay_before_tax?:
-  - :done
-  - :done_no_statutory
-  :years_employed?:
-  - :done_no_statutory
-  - :weekly_pay_before_tax?
-calculate-married-couples-allowance:
-  :did_you_marry_or_civil_partner_before_5_december_2005?:
-  - :whats_the_highest_earners_date_of_birth?
-  - :whats_the_husbands_date_of_birth?
-  :how_much_expected_contributions_before_tax?:
-  - :how_much_expected_contributions_with_tax_relief?
-  :how_much_expected_contributions_with_tax_relief?:
-  - :how_much_expected_gift_aided_donations?
-  :how_much_expected_gift_aided_donations?:
-  - :highest_earner_done
-  - :husband_done
-  :paying_into_a_pension?:
-  - :how_much_expected_contributions_before_tax?
-  - :how_much_expected_gift_aided_donations?
-  :were_you_or_your_partner_born_on_or_before_6_april_1935?:
-  - :did_you_marry_or_civil_partner_before_5_december_2005?
-  - :sorry
-  :whats_the_highest_earners_date_of_birth?:
-  - :whats_the_highest_earners_income?
-  :whats_the_highest_earners_income?:
-  - :highest_earner_done
-  - :paying_into_a_pension?
-  :whats_the_husbands_date_of_birth?:
-  - :whats_the_husbands_income?
-  :whats_the_husbands_income?:
-  - :husband_done
-  - :paying_into_a_pension?
-calculate-statutory-sick-pay:
-  :contractual_days_covered_by_earnings?:
-  - :usual_work_days?
-  :days_covered_by_earnings?:
-  - :usual_work_days?
-  :employee_tell_within_limit?:
-  - :employee_work_different_days?
-  :employee_work_different_days?:
-  - :first_sick_day?
-  - :not_regular_schedule
-  :first_sick_day?:
-  - :last_sick_day?
-  :has_linked_sickness?:
-  - :linked_sickness_start_date?
-  - :paid_at_least_8_weeks?
-  :how_often_pay_employee_pay_patterns?:
-  - :last_payday_before_sickness?
-  - :pay_amount_if_not_sick?
-  :is_your_employee_getting?:
-  - :already_getting_maternity
-  - :employee_tell_within_limit?
-  :last_payday_before_offset?:
-  - :total_employee_earnings?
-  :last_payday_before_sickness?:
-  - :last_payday_before_offset?
-  :last_sick_day?:
-  - :has_linked_sickness?
-  - :must_be_sick_for_4_days
-  :linked_sickness_end_date?:
-  - :paid_at_least_8_weeks?
-  :linked_sickness_start_date?:
-  - :linked_sickness_end_date?
-  :paid_at_least_8_weeks?:
-  - :how_often_pay_employee_pay_patterns?
-  - :total_earnings_before_sick_period?
-  :pay_amount_if_not_sick?:
-  - :contractual_days_covered_by_earnings?
-  :total_earnings_before_sick_period?:
-  - :days_covered_by_earnings?
-  :total_employee_earnings?:
-  - :usual_work_days?
-  :usual_work_days?:
-  - :entitled_to_sick_pay
-  - :maximum_entitlement_reached
-  - :not_earned_enough
-  - :not_entitled_3_days_not_paid
-calculate-your-child-maintenance:
-  :are_you_paying_or_receiving?:
-  - :how_many_children_paid_for?
-  :gets_benefits?:
-  - :gross_income_of_payee?
-  - :how_many_nights_children_stay_with_payee?
-  :gross_income_of_payee?:
-  - :flat_rate_result
-  - :how_many_other_children_in_payees_household?
-  - :nil_rate_result
-  :how_many_children_paid_for?:
-  - :gets_benefits?
-  :how_many_nights_children_stay_with_payee?:
-  - :flat_rate_result
-  - :nil_rate_result
-  - :reduced_and_basic_rates_result
-  :how_many_other_children_in_payees_household?:
-  - :how_many_nights_children_stay_with_payee?
-calculate-your-holiday-entitlement:
-  :annualised_hours?:
-  - :annualised_hours_done
-  :basis_of_calculation?:
-  - :annualised_hours?
-  - :calculation_period?
-  - :casual_or_irregular_hours?
-  - :compressed_hours_how_many_hours_per_week?
-  - :shift_worker_basis?
-  :calculation_period?:
-  - :how_many_days_per_week?
-  - :how_many_hours_per_week?
-  - :what_is_your_leaving_date?
-  - :what_is_your_starting_date?
-  :casual_or_irregular_hours?:
-  - :casual_or_irregular_hours_done
-  :compressed_hours_how_many_days_per_week?:
-  - :compressed_hours_done
-  :compressed_hours_how_many_hours_per_week?:
-  - :compressed_hours_how_many_days_per_week?
-  :how_many_days_per_week?:
-  - :days_per_week_done
-  :how_many_hours_per_week?:
-  - :hours_per_week_done
-  :shift_worker_basis?:
-  - :shift_worker_hours_per_shift?
-  - :what_is_your_leaving_date?
-  - :what_is_your_starting_date?
-  :shift_worker_days_per_shift_pattern?:
-  - :shift_worker_done
-  :shift_worker_hours_per_shift?:
-  - :shift_worker_shifts_per_shift_pattern?
-  :shift_worker_shifts_per_shift_pattern?:
-  - :shift_worker_days_per_shift_pattern?
-  :what_is_your_leaving_date?:
-  - :how_many_days_per_week?
-  - :how_many_hours_per_week?
-  - :shift_worker_hours_per_shift?
-  - :when_does_your_leave_year_start?
-  :what_is_your_starting_date?:
-  - :what_is_your_leaving_date?
-  - :when_does_your_leave_year_start?
-  :when_does_your_leave_year_start?:
-  - :how_many_days_per_week?
-  - :how_many_hours_per_week?
-  - :shift_worker_hours_per_shift?
-calculate-your-redundancy-pay:
-  :age_of_employee?:
-  - :years_employed?
-  :date_of_redundancy?:
-  - :age_of_employee?
-  :weekly_pay_before_tax?:
-  - :done
-  - :done_no_statutory
-  :years_employed?:
-  - :done_no_statutory
-  - :weekly_pay_before_tax?
-check-uk-visa:
-  :israeli_document_type?:
-  - :purpose_of_visit?
-  :passing_through_uk_border_control?:
-  - :outcome_no_visa_needed
-  - :outcome_transit_leaving_airport
-  - :outcome_transit_leaving_airport_datv
-  - :outcome_transit_not_leaving_airport
-  - :outcome_transit_refugee_not_leaving_airport
-  - :outcome_transit_taiwan
-  - :outcome_transit_taiwan_through_border_control
-  - :outcome_transit_venezuela
-  :purpose_of_visit?:
-  - :outcome_diplomatic_business
-  - :outcome_joining_family_m
-  - :outcome_joining_family_nvn
-  - :outcome_joining_family_y
-  - :outcome_marriage
-  - :outcome_medical_n
-  - :outcome_medical_y
-  - :outcome_no_visa_needed
-  - :outcome_school_n
-  - :outcome_school_waiver
-  - :outcome_school_y
-  - :outcome_standard_visit
-  - :outcome_taiwan_exception
-  - :outcome_visit_waiver
-  - :passing_through_uk_border_control?
-  - :staying_for_how_long?
-  :staying_for_how_long?:
-  - :outcome_no_visa_needed
-  - :outcome_study_m
-  - :outcome_study_waiver
-  - :outcome_study_y
-  - :outcome_taiwan_exception
-  - :outcome_work_m
-  - :outcome_work_n
-  - :outcome_work_waiver
-  - :outcome_work_y
-  :what_passport_do_you_have?:
-  - :israeli_document_type?
-  - :outcome_no_visa_needed
-  - :purpose_of_visit?
-childcare-costs-for-tax-credits:
-  :currently_claiming?:
-  - :have_costs_changed?
-  - :how_often_use_childcare?
-  :have_costs_changed?:
-  - :how_often_pay_2?
-  - :no_change
-  :how_much_12_months_1?:
-  - :weekly_costs_are_x
-  :how_much_12_months_2?:
-  - :no_longer_paying
-  - :old_weekly_amount_1?
-  :how_much_4_weeks?:
-  - :weekly_costs_are_x
-  :how_much_52_weeks_1?:
-  - :weekly_costs_are_x
-  :how_much_52_weeks_2?:
-  - :no_longer_paying
-  - :old_weekly_amount_1?
-  :how_much_each_month?:
-  - :weekly_costs_are_x
-  :how_much_fortnightly?:
-  - :weekly_costs_are_x
-  :how_much_spent_last_12_months?:
-  - :weekly_costs_are_x
-  :how_much_yearly?:
-  - :weekly_costs_are_x
-  :how_often_pay_1?:
-  - :how_much_12_months_1?
-  - :how_much_52_weeks_1?
-  - :how_much_each_month?
-  - :round_up_weekly
-  :how_often_pay_2?:
-  - :how_much_12_months_2?
-  - :how_much_52_weeks_2?
-  - :new_monthly_cost?
-  - :new_weekly_costs?
-  :how_often_pay_providers?:
-  - :call_helpline_plain
-  - :how_much_4_weeks?
-  - :how_much_each_month?
-  - :how_much_fortnightly?
-  - :how_much_yearly?
-  - :round_up_weekly
-  :how_often_use_childcare?:
-  - :call_helpline_detailed
-  - :how_often_pay_1?
-  - :pay_same_each_time?
-  :new_monthly_cost?:
-  - :no_longer_paying
-  - :old_weekly_amount_3?
-  :new_weekly_costs?:
-  - :no_longer_paying
-  - :old_weekly_amount_2?
-  :old_weekly_amount_1?:
-  - :cost_changed
-  :old_weekly_amount_2?:
-  - :cost_changed
-  :old_weekly_amount_3?:
-  - :cost_changed
-  :pay_same_each_time?:
-  - :how_much_spent_last_12_months?
-  - :how_often_pay_providers?
-energy-grants-calculator:
-  :date_of_birth?:
-  - :outcome_help_with_bills
-  - :when_property_built?
-  - :which_benefits?
-  :disabled_or_have_children?:
-  - :outcome_help_with_bills
-  - :when_property_built?
-  :home_features_historic?:
-  - :outcome_bills_and_measures_no_benefits
-  - :outcome_bills_and_measures_on_benefits_eco_eligible
-  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
-  - :outcome_measures_help_green_deal
-  :home_features_modern?:
-  - :outcome_bills_and_measures_no_benefits
-  - :outcome_bills_and_measures_on_benefits_eco_eligible
-  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
-  - :outcome_measures_help_green_deal
-  - :outcome_no_green_deal_no_energy_measures
-  :home_features_older?:
-  - :outcome_bills_and_measures_no_benefits
-  - :outcome_bills_and_measures_on_benefits_eco_eligible
-  - :outcome_bills_and_measures_on_benefits_not_eco_eligible
-  - :outcome_measures_help_green_deal
-  :type_of_flat?:
-  - :home_features_historic?
-  - :home_features_modern?
-  - :home_features_older?
-  :type_of_property?:
-  - :home_features_historic?
-  - :home_features_modern?
-  - :home_features_older?
-  - :type_of_flat?
-  :what_are_you_looking_for?:
-  - :what_are_your_circumstances?
-  - :what_are_your_circumstances_without_bills_help?
-  :what_are_your_circumstances?:
-  - :date_of_birth?
-  :what_are_your_circumstances_without_bills_help?:
-  - :date_of_birth?
-  - :when_property_built?
-  - :which_benefits?
-  :when_property_built?:
-  - :type_of_property?
-  :which_benefits?:
-  - :disabled_or_have_children?
-  - :outcome_help_with_bills
-  - :when_property_built?
-estimate-self-assessment-penalties:
-  :how_much_tax?:
-  - :late
-  :how_submitted?:
-  - :when_submitted?
-  :when_paid?:
-  - :filed_and_paid_on_time
-  - :how_much_tax?
-  :when_submitted?:
-  - :when_paid?
-  :which_year?:
-  - :how_submitted?
-help-if-you-are-arrested-abroad:
-  :which_country?:
-  - :answer_one_generic
-  - :answer_three_syria
-  - :answer_two_iran
-inherits-someone-dies-without-will:
-  :aunts_or_uncles?:
-  - :grandparents?
-  - :half_aunts_or_uncles?
-  - :outcome_6
-  - :outcome_67
-  :children?:
-  - :more_than_one_child?
-  - :outcome_1
-  - :outcome_2
-  - :outcome_20
-  - :outcome_40
-  - :outcome_66
-  - :parents?
-  :estate_over_250000?:
-  - :children?
-  - :outcome_1
-  - :outcome_60
-  :grandparents?:
-  - :aunts_or_uncles?
-  - :great_aunts_or_uncles?
-  - :outcome_5
-  :great_aunts_or_uncles?:
-  - :outcome_45
-  - :outcome_46
-  :half_aunts_or_uncles?:
-  - :outcome_24
-  - :outcome_25
-  :half_siblings?:
-  - :grandparents?
-  - :outcome_23
-  :more_than_one_child?:
-  - :outcome_61
-  - :outcome_62
-  :parents?:
-  - :outcome_3
-  - :outcome_63
-  - :siblings?
-  - :siblings_including_mixed_parents?
-  :partner?:
-  - :children?
-  - :estate_over_250000?
-  :region?:
-  - :partner?
-  :siblings?:
-  - :aunts_or_uncles?
-  - :grandparents?
-  - :half_siblings?
-  - :outcome_1
-  - :outcome_3
-  - :outcome_4
-  - :outcome_41
-  - :outcome_42
-  - :outcome_43
-  - :outcome_44
-  :siblings_including_mixed_parents?:
-  - :outcome_64
-  - :outcome_65
-landlord-immigration-check:
-  :has_asylum_card?:
-  - :immigration_application?
-  - :outcome_can_rent_for_12_months
-  :has_certificate?:
-  - :outcome_can_rent
-  - :tenant_country?
-  :has_documents?:
-  - :has_other_documents?
-  - :outcome_can_rent
-  :has_other_documents?:
-  - :outcome_can_rent
-  - :time_limited_to_remain?
-  :has_residence_card_or_eu_eea_swiss_family_member?:
-  - :has_asylum_card?
-  - :outcome_can_rent
-  :has_uk_passport?:
-  - :outcome_can_rent
-  - :right_to_abode?
-  :immigration_application?:
-  - :outcome_can_not_rent
-  - :outcome_can_rent_for_12_months
-  :main_home?:
-  - :property_type?
-  - :tenant_over_18?
-  :property?:
-  - :main_home?
-  - :outcome_check_not_needed
-  :property_type?:
-  - :outcome_check_may_be_needed_when_student
-  - :outcome_check_needed_if_break_clause
-  - :outcome_check_not_needed
-  - :outcome_check_not_needed_if_holiday_or_under_3_months
-  - :outcome_check_not_needed_when_care_home
-  - :outcome_check_not_needed_when_employee_home
-  - :outcome_check_not_needed_when_hostel_refuge
-  - :outcome_check_not_needed_when_mobile_home
-  :right_to_abode?:
-  - :has_certificate?
-  - :outcome_can_rent
-  :tenant_country?:
-  - :has_documents?
-  - :has_other_documents?
-  - :has_residence_card_or_eu_eea_swiss_family_member?
-  :tenant_over_18?:
-  - :has_uk_passport?
-  - :outcome_check_not_needed_when_under_18
-  :time_limited_to_remain?:
-  - :has_residence_card_or_eu_eea_swiss_family_member?
-  - :outcome_can_rent_but_check_will_be_needed_again
-legalisation-document-checker:
-  :which_documents_do_you_want_legalised?:
-  - :outcome_results
-marriage-abroad:
-  :country_of_ceremony?:
-  - :legal_residency?
-  - :marriage_or_pacs?
-  - :outcome_os_france_or_fot
-  - :partner_opposite_or_same_sex?
-  :legal_residency?:
-  - :partner_opposite_or_same_sex?
-  - :what_is_your_partners_nationality?
-  :marriage_or_pacs?:
-  - :outcome_cp_france_pacs
-  - :outcome_monaco
-  - :outcome_os_france_or_fot
-  :partner_opposite_or_same_sex?:
-  - :outcome_brazil_not_living_in_the_uk
-  - :outcome_consular_cni_os_residing_in_third_country
-  - :outcome_cp_all_other_countries
-  - :outcome_cp_commonwealth_countries
-  - :outcome_cp_consular
-  - :outcome_cp_no_cni
-  - :outcome_cp_or_equivalent
-  - :outcome_ireland
-  - :outcome_marriage_via_local_authorities
-  - :outcome_os_affirmation
-  - :outcome_os_belarus
-  - :outcome_os_bot
-  - :outcome_os_cambodia
-  - :outcome_os_colombia
-  - :outcome_os_commonwealth
-  - :outcome_os_consular_cni
-  - :outcome_os_germany
-  - :outcome_os_hong_kong
-  - :outcome_os_indonesia
-  - :outcome_os_italy
-  - :outcome_os_japan
-  - :outcome_os_kosovo
-  - :outcome_os_kuwait
-  - :outcome_os_laos
-  - :outcome_os_marriage_impossible_no_laos_locals
-  - :outcome_os_no_cni
-  - :outcome_os_oman
-  - :outcome_os_other_countries
-  - :outcome_os_poland
-  - :outcome_os_slovenia
-  - :outcome_portugal
-  - :outcome_spain
-  - :outcome_ss_affirmation
-  - :outcome_ss_marriage
-  - :outcome_ss_marriage_malta
-  - :outcome_ss_marriage_not_possible
-  - :outcome_switzerland
-  :what_is_your_partners_nationality?:
-  - :partner_opposite_or_same_sex?
-maternity-paternity-calculator:
-  :adoption_date_leave_starts?:
-  - :adoption_leave_and_pay
-  - :last_normal_payday_adoption?
-  :adoption_did_the_employee_work_for_you?:
-  - :adoption_employment_contract?
-  - :adoption_not_entitled_to_leave_or_pay
-  :adoption_employment_contract?:
-  - :adoption_is_the_employee_on_your_payroll?
-  :adoption_is_the_employee_on_your_payroll?:
-  - :adoption_date_leave_starts?
-  - :adoption_not_entitled_to_leave_or_pay
-  :baby_birth_date_paternity?:
-  - :employee_responsible_for_upbringing?
-  :baby_due_date_maternity?:
-  - :employment_contract?
-  :baby_due_date_paternity?:
-  - :baby_birth_date_paternity?
-  :date_leave_starts?:
-  - :did_the_employee_work_for_you?
-  :date_of_adoption_match?:
-  - :date_of_adoption_placement?
-  :date_of_adoption_placement?:
-  - :adoption_did_the_employee_work_for_you?
-  :day_of_the_month_paternity?:
-  - :pay_date_options_paternity?
-  :days_of_the_week_paternity?:
-  - :adoption_leave_and_pay
-  - :paternity_leave_and_pay
-  :did_the_employee_work_for_you?:
-  - :is_the_employee_on_your_payroll?
-  - :maternity_leave_and_pay_result
-  :earnings_for_pay_period?:
-  - :how_do_you_want_the_smp_calculated?
-  :earnings_for_pay_period_adoption?:
-  - :adoption_leave_and_pay
-  - :how_do_you_want_the_sap_calculated?
-  :earnings_for_pay_period_paternity?:
-  - :how_do_you_want_the_spp_calculated?
-  - :paternity_leave_and_pay
-  :employee_date_matched_paternity_adoption?:
-  - :padoption_date_of_adoption_placement?
-  :employee_has_contract_paternity?:
-  - :employee_on_payroll_paternity?
-  :employee_on_payroll_paternity?:
-  - :employee_start_paternity?
-  - :employee_still_employed_on_birth_date?
-  - :paternity_not_entitled_to_leave_or_pay
-  :employee_paternity_length?:
-  - :last_normal_payday_paternity?
-  - :paternity_not_entitled_to_leave_or_pay
-  :employee_responsible_for_upbringing?:
-  - :employee_work_before_employment_start?
-  - :paternity_not_entitled_to_leave_or_pay
-  :employee_start_paternity?:
-  - :employee_paternity_length?
-  :employee_still_employed_on_birth_date?:
-  - :employee_start_paternity?
-  - :paternity_not_entitled_to_leave_or_pay
-  :employee_work_before_employment_start?:
-  - :employee_has_contract_paternity?
-  - :paternity_not_entitled_to_leave_or_pay
-  :employment_contract?:
-  - :date_leave_starts?
-  :how_do_you_want_the_sap_calculated?:
-  - :adoption_leave_and_pay
-  - :monthly_pay_paternity?
-  - :next_pay_day_paternity?
-  :how_do_you_want_the_smp_calculated?:
-  - :maternity_leave_and_pay_result
-  - :when_in_the_month_is_the_employee_paid?
-  - :when_is_your_employees_next_pay_day?
-  :how_do_you_want_the_spp_calculated?:
-  - :monthly_pay_paternity?
-  - :next_pay_day_paternity?
-  - :paternity_leave_and_pay
-  :is_the_employee_on_your_payroll?:
-  - :last_normal_payday?
-  - :maternity_leave_and_pay_result
-  :last_normal_payday?:
-  - :payday_eight_weeks?
-  :last_normal_payday_adoption?:
-  - :payday_eight_weeks_adoption?
-  :last_normal_payday_paternity?:
-  - :payday_eight_weeks_paternity?
-  :leave_or_pay_for_adoption?:
-  - :baby_due_date_paternity?
-  - :employee_date_matched_paternity_adoption?
-  :monthly_pay_paternity?:
-  - :adoption_leave_and_pay
-  - :day_of_the_month_paternity?
-  - :days_of_the_week_paternity?
-  - :paternity_leave_and_pay
-  - :specific_date_each_month_paternity?
-  :next_pay_day_paternity?:
-  - :paternity_leave_and_pay
-  :padoption_date_of_adoption_placement?:
-  - :padoption_employee_responsible_for_upbringing?
-  :padoption_employee_responsible_for_upbringing?:
-  - :employee_work_before_employment_start?
-  - :paternity_not_entitled_to_leave_or_pay
-  :pay_date_options_paternity?:
-  - :adoption_leave_and_pay
-  - :paternity_leave_and_pay
-  :pay_frequency?:
-  - :earnings_for_pay_period?
-  :pay_frequency_adoption?:
-  - :earnings_for_pay_period_adoption?
-  :pay_frequency_paternity?:
-  - :earnings_for_pay_period_paternity?
-  :payday_eight_weeks?:
-  - :pay_frequency?
-  :payday_eight_weeks_adoption?:
-  - :pay_frequency_adoption?
-  :payday_eight_weeks_paternity?:
-  - :pay_frequency_paternity?
-  :specific_date_each_month_paternity?:
-  - :adoption_leave_and_pay
-  - :paternity_leave_and_pay
-  :taking_paternity_leave_for_adoption?:
-  - :date_of_adoption_match?
-  - :employee_date_matched_paternity_adoption?
-  :what_days_does_the_employee_work?:
-  - :maternity_leave_and_pay_result
-  :what_particular_day_of_the_month_is_the_employee_paid?:
-  - :which_week_in_month_is_the_employee_paid?
-  :what_specific_date_each_month_is_the_employee_paid?:
-  - :maternity_leave_and_pay_result
-  :what_type_of_leave?:
-  - :baby_due_date_maternity?
-  - :leave_or_pay_for_adoption?
-  - :taking_paternity_leave_for_adoption?
-  :when_in_the_month_is_the_employee_paid?:
-  - :maternity_leave_and_pay_result
-  - :what_days_does_the_employee_work?
-  - :what_particular_day_of_the_month_is_the_employee_paid?
-  - :what_specific_date_each_month_is_the_employee_paid?
-  :when_is_your_employees_next_pay_day?:
-  - :maternity_leave_and_pay_result
-  :which_week_in_month_is_the_employee_paid?:
-  - :maternity_leave_and_pay_result
-minimum-wage-calculator-employers:
-  :are_you_an_apprentice?:
-  - :how_often_do_you_get_paid?
-  - :how_old_are_you?
-  :current_accommodation_charge?:
-  - :current_accommodation_usage?
-  :current_accommodation_usage?:
-  - :current_payment_above
-  - :current_payment_below
-  :how_many_hours_did_you_work?:
-  - :how_much_were_you_paid_during_pay_period?
-  :how_many_hours_do_you_work?:
-  - :how_much_are_you_paid_during_pay_period?
-  :how_many_hours_overtime_did_you_work?:
-  - :was_provided_with_accommodation?
-  - :what_was_overtime_pay_per_hour?
-  :how_many_hours_overtime_do_you_work?:
-  - :is_provided_with_accommodation?
-  - :what_is_overtime_pay_per_hour?
-  :how_much_are_you_paid_during_pay_period?:
-  - :how_many_hours_overtime_do_you_work?
-  :how_much_were_you_paid_during_pay_period?:
-  - :how_many_hours_overtime_did_you_work?
-  :how_often_did_you_get_paid?:
-  - :how_many_hours_did_you_work?
-  :how_often_do_you_get_paid?:
-  - :how_many_hours_do_you_work?
-  :how_old_are_you?:
-  - :how_often_do_you_get_paid?
-  - :under_school_leaving_age
-  :how_old_were_you?:
-  - :how_often_did_you_get_paid?
-  - :under_school_leaving_age_past
-  :is_provided_with_accommodation?:
-  - :current_accommodation_charge?
-  - :current_accommodation_usage?
-  - :current_payment_above
-  - :current_payment_below
-  :past_accommodation_charge?:
-  - :past_accommodation_usage?
-  :past_accommodation_usage?:
-  - :past_payment_above
-  - :past_payment_below
-  :past_payment_date?:
-  - :were_you_an_apprentice?
-  :was_provided_with_accommodation?:
-  - :past_accommodation_charge?
-  - :past_accommodation_usage?
-  - :past_payment_above
-  - :past_payment_below
-  :were_you_an_apprentice?:
-  - :does_not_apply_to_historical_apprentices
-  - :how_often_did_you_get_paid?
-  - :how_old_were_you?
-  :what_is_overtime_pay_per_hour?:
-  - :is_provided_with_accommodation?
-  :what_was_overtime_pay_per_hour?:
-  - :was_provided_with_accommodation?
-  :what_would_you_like_to_check?:
-  - :are_you_an_apprentice?
-  - :past_payment_date?
-overseas-passports:
-  :child_or_adult_passport?:
-  - :country_of_birth?
-  - :ips_application_result
-  - :ips_application_result_online
-  :country_of_birth?:
-  - :ips_application_result
-  - :ips_application_result_online
-  :renewing_replacing_applying?:
-  - :child_or_adult_passport?
-  :which_country_are_you_in?:
-  - :apply_in_neighbouring_country
-  - :cannot_apply
-  - :renewing_replacing_applying?
-  - :which_opt?
-  :which_opt?:
-  - :renewing_replacing_applying?
-part-year-profit-tax-credits:
-  :did_you_start_trading_before_the_relevant_accounting_year?:
-  - :when_did_you_start_trading?
-  - :when_did_you_stop_trading?
-  :do_your_accounts_cover_a_12_month_period?:
-  - :what_is_your_taxable_profit?
-  - :when_did_you_start_trading?
-  :have_you_stopped_trading?:
-  - :did_you_start_trading_before_the_relevant_accounting_year?
-  - :do_your_accounts_cover_a_12_month_period?
-  :what_date_do_your_accounts_go_up_to?:
-  - :have_you_stopped_trading?
-  :what_is_your_taxable_profit?:
-  - :result
-  :when_did_you_start_trading?:
-  - :what_is_your_taxable_profit?
-  - :when_did_you_stop_trading?
-  :when_did_you_stop_trading?:
-  - :what_is_your_taxable_profit?
-  :when_did_your_tax_credits_award_end?:
-  - :what_date_do_your_accounts_go_up_to?
-pay-leave-for-parents:
-  :due_date:
-  - :employment_status_of_mother
-  :employment_status_of_mother:
-  - :employment_status_of_partner
-  - :mother_started_working_before_continuity_start_date
-  - :mother_worked_at_least_26_weeks
-  :employment_status_of_partner:
-  - :mother_started_working_before_continuity_start_date
-  - :mother_worked_at_least_26_weeks
-  :mother_earned_at_least_390:
-  - :outcome_birth_nothing
-  - :outcome_mat_allowance_14_weeks
-  - :outcome_mat_leave
-  - :outcome_single_birth_nothing
-  - :partner_started_working_before_continuity_start_date
-  - :partner_worked_at_least_26_weeks
-  - :salary_1_66_weeks
-  :mother_earned_more_than_lower_earnings_limit:
-  - :mother_worked_at_least_26_weeks
-  - :outcome_mat_leave_mat_pay
-  - :outcome_mat_pay
-  - :partner_started_working_before_continuity_start_date
-  - :partner_worked_at_least_26_weeks
-  :mother_salary:
-  - :mother_earned_more_than_lower_earnings_limit
-  :mother_started_working_before_continuity_start_date:
-  - :mother_still_working_on_continuity_end_date
-  :mother_still_working_on_continuity_end_date:
-  - :mother_salary
-  :mother_worked_at_least_26_weeks:
-  - :mother_earned_at_least_390
-  :partner_earned_at_least_390:
-  - :outcome_mat_allowance_mat_leave
-  - :outcome_mat_allowance_mat_leave_mat_shared_leave
-  - :outcome_mat_allowance_mat_leave_pat_leave_both_shared_leave
-  - :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
-  - :outcome_mat_leave
-  - :outcome_mat_leave_mat_pay
-  - :outcome_mat_leave_mat_pay_mat_shared_leave_mat_shared_pay
-  - :outcome_mat_leave_mat_pay_pat_leave_both_shared_leave_mat_shared_pay
-  - :outcome_mat_leave_mat_pay_pat_leave_pat_shared_leave
-  - :outcome_mat_leave_mat_shared_leave
-  - :outcome_mat_leave_pat_leave
-  - :outcome_mat_leave_pat_leave_mat_shared_leave
-  - :outcome_mat_pay
-  - :outcome_mat_pay_mat_shared_pay
-  - :outcome_mat_pay_pat_leave
-  - :outcome_mat_pay_pat_leave_pat_shared_leave_mat_shared_pay
-  :partner_earned_more_than_lower_earnings_limit:
-  - :outcome_birth_nothing
-  - :outcome_mat_allowance
-  - :outcome_mat_allowance_mat_leave
-  - :outcome_mat_allowance_mat_leave_pat_leave_additional_pat_leave
-  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
-  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_both_shared_leave_pat_shared_pay
-  - :outcome_mat_allowance_mat_leave_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
-  - :outcome_mat_allowance_mat_leave_pat_leave_pat_shared_leave
-  - :outcome_mat_allowance_mat_leave_pat_pay_additional_pat_pay
-  - :outcome_mat_allowance_mat_leave_pat_pay_mat_shared_leave_pat_shared_pay
-  - :outcome_mat_allowance_mat_leave_pat_pay_pat_shared_pay
-  - :outcome_mat_allowance_pat_leave_additional_pat_leave
-  - :outcome_mat_allowance_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
-  - :outcome_mat_allowance_pat_leave_pat_pay_pat_shared_leave_pat_shared_pay
-  - :outcome_mat_allowance_pat_leave_pat_shared_leave
-  - :outcome_mat_allowance_pat_pay_additional_pat_pay
-  - :outcome_mat_allowance_pat_pay_pat_shared_pay
-  - :outcome_mat_leave
-  - :outcome_mat_leave_mat_pay
-  - :outcome_mat_leave_mat_pay_pat_leave_additional_pat_leave
-  - :outcome_mat_leave_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
-  - :outcome_mat_leave_mat_pay_pat_leave_pat_pay_both_shared_leave_both_shared_pay
-  - :outcome_mat_leave_mat_pay_pat_pay_additional_pat_pay
-  - :outcome_mat_leave_mat_pay_pat_pay_mat_shared_leave_both_shared_pay
-  - :outcome_mat_leave_pat_leave
-  - :outcome_mat_leave_pat_leave_additional_pat_leave
-  - :outcome_mat_leave_pat_leave_pat_pay
-  - :outcome_mat_leave_pat_leave_pat_pay_additional_pat_leave
-  - :outcome_mat_leave_pat_leave_pat_pay_mat_shared_leave
-  - :outcome_mat_leave_pat_pay
-  - :outcome_mat_leave_pat_pay_mat_shared_leave
-  - :outcome_mat_pay
-  - :outcome_mat_pay_pat_leave_additional_pat_leave
-  - :outcome_mat_pay_pat_leave_pat_pay_additional_pat_leave_additional_pat_pay
-  - :outcome_mat_pay_pat_leave_pat_pay_pat_shared_leave_both_shared_pay
-  - :outcome_mat_pay_pat_pay_additional_pat_pay
-  - :outcome_mat_pay_pat_pay_both_shared_pay
-  - :outcome_pat_leave
-  - :outcome_pat_leave_pat_pay
-  - :outcome_pat_pay
-  - :partner_worked_at_least_26_weeks
-  :partner_salary:
-  - :partner_earned_more_than_lower_earnings_limit
-  :partner_started_working_before_continuity_start_date:
-  - :partner_still_working_on_continuity_end_date
-  :partner_still_working_on_continuity_end_date:
-  - :partner_salary
-  :partner_worked_at_least_26_weeks:
-  - :partner_earned_at_least_390
-  :salary_1_66_weeks:
-  - :outcome_mat_allowance
-  - :outcome_mat_allowance_mat_leave
-  - :partner_started_working_before_continuity_start_date
-  - :partner_worked_at_least_26_weeks
-  :two_carers:
-  - :due_date
-pip-checker:
-  :are_you_getting_dla?:
-  - :what_is_your_dob?
-  :what_is_your_dob?:
-  - :result_1
-  - :result_2
-  - :result_3
-  - :result_5
-  - :result_6
-  - :result_7
-plan-adoption-leave:
-  :child_arrival_date?:
-  - :leave_start?
-  :child_match_date?:
-  - :child_arrival_date?
-  :leave_start?:
-  - :adoption_leave_details
-register-a-birth:
-  :childs_date_of_birth?:
-  - :homeoffice_result
-  - :where_are_you_now?
-  :country_of_birth?:
-  - :commonwealth_result
-  - :no_embassy_result
-  - :who_has_british_nationality?
-  :married_couple_or_civil_partnership?:
-  - :childs_date_of_birth?
-  - :where_are_you_now?
-  :where_are_you_now?:
-  - :no_birth_certificate_result
-  - :north_korea_result
-  - :oru_result
-  - :which_country?
-  :which_country?:
-  - :north_korea_result
-  - :oru_result
-  :who_has_british_nationality?:
-  - :married_couple_or_civil_partnership?
-  - :no_registration_result
-register-a-death:
-  :did_the_person_die_at_home_hospital?:
-  - :was_death_expected?
-  :was_death_expected?:
-  - :uk_result
-  :where_are_you_now?:
-  - :north_korea_result
-  - :oru_result
-  - :which_country_are_you_in_now?
-  :where_did_the_death_happen?:
-  - :did_the_person_die_at_home_hospital?
-  - :which_country?
-  :which_country?:
-  - :commonwealth_result
-  - :no_embassy_result
-  - :where_are_you_now?
-  :which_country_are_you_in_now?:
-  - :north_korea_result
-  - :oru_result
-report-a-lost-or-stolen-passport:
-  :where_was_the_passport_lost_or_stolen?:
-  - :complete_LS01_form
-  - :which_country?
-  :which_country?:
-  - :contact_the_embassy
-  - :contact_the_embassy_canada
-simplified-expenses-checker:
-  :buying_new_vehicle?:
-  - :capital_allowances?
-  - :how_much_expect_to_claim?
-  - :is_vehicle_green?
-  :capital_allowances?:
-  - :capital_allowance_result
-  - :deduct_from_premises?
-  - :hours_work_home?
-  - :how_much_expect_to_claim?
-  :claimed_expenses_for_current_business?:
-  - :type_of_expense?
-  :current_claim_amount_home?:
-  - :deduct_from_premises?
-  - :you_can_use_result
-  :deduct_from_premises?:
-  - :people_live_on_premises?
-  :drive_business_miles_car_van?:
-  - :deduct_from_premises?
-  - :drive_business_miles_motorcycle?
-  - :hours_work_home?
-  - :you_can_use_result
-  :drive_business_miles_motorcycle?:
-  - :deduct_from_premises?
-  - :hours_work_home?
-  - :you_can_use_result
-  :hours_work_home?:
-  - :current_claim_amount_home?
-  - :you_cant_use_result
-  :how_much_expect_to_claim?:
-  - :drive_business_miles_car_van?
-  - :drive_business_miles_motorcycle?
-  :is_vehicle_green?:
-  - :price_of_vehicle?
-  :people_live_on_premises?:
-  - :you_can_use_result
-  :price_of_vehicle?:
-  - :vehicle_business_use_time?
-  :type_of_expense?:
-  - :buying_new_vehicle?
-  - :deduct_from_premises?
-  - :hours_work_home?
-  - :you_cant_use_result
-  :vehicle_business_use_time?:
-  - :drive_business_miles_car_van?
-  - :drive_business_miles_motorcycle?
-state-pension-age:
-  :dob_age?:
-  - :bus_pass_result
-  - :gender?
-  :gender?:
-  - :has_reached_sp_age
-  - :not_yet_reached_sp_age
-  :which_calculation?:
-  - :dob_age?
-state-pension-through-partner:
-  :what_is_your_gender?:
-  - :age_dependent_pension_outcome
-  - :impossibility_due_to_divorce_outcome
-  - :impossibility_to_increase_pension_outcome
-  - :married_woman_and_state_pension_outcome
-  - :married_woman_no_state_pension_outcome
-  :what_is_your_marital_status?:
-  - :what_is_your_gender?
-  - :when_will_you_reach_pension_age?
-  :when_will_you_reach_pension_age?:
-  - :what_is_your_gender?
-  - :when_will_your_partner_reach_pension_age?
-  - :widow_and_old_pension_outcome
-  :when_will_your_partner_reach_pension_age?:
-  - :current_rules_national_insurance_no_state_pension_outcome
-  - :current_rules_no_additional_pension_outcome
-  - :what_is_your_gender?
-state-pension-topup:
-  :dob_age?:
-  - :gender?
-  - :outcome_pension_age_not_reached
-  :gender?:
-  - :how_much_extra_per_week?
-  - :outcome_pension_age_not_reached
-  :how_much_extra_per_week?:
-  - :outcome_topup_calculations
-student-finance-calculator:
-  :do_any_of_the_following_apply_all_uk_students?:
-  - :what_course_are_you_studying?
-  :do_any_of_the_following_apply_uk_full_time_students_only?:
-  - :what_course_are_you_studying?
-  :how_much_are_your_tuition_fees_per_year?:
-  - :do_any_of_the_following_apply_all_uk_students?
-  - :outcome_eu_students
-  - :where_will_you_live_while_studying?
-  :what_course_are_you_studying?:
-  - :outcome_eu_students
-  - :outcome_uk_all_students
-  - :outcome_uk_full_time_students
-  :what_type_of_student_are_you?:
-  - :how_much_are_your_tuition_fees_per_year?
-  :whats_your_household_income?:
-  - :do_any_of_the_following_apply_uk_full_time_students_only?
-  :when_does_your_course_start?:
-  - :what_type_of_student_are_you?
-  :where_will_you_live_while_studying?:
-  - :whats_your_household_income?
-student-finance-forms:
-  :continuing_student?:
-  - :outcome_eu_ft_1516_continuing
-  - :outcome_eu_ft_1516_new
-  - :outcome_eu_ft_1617_continuing
-  - :outcome_eu_ft_1617_new
-  - :outcome_eu_pt_1415_continuing
-  - :outcome_eu_pt_1415_new
-  - :outcome_eu_pt_1516_continuing
-  - :outcome_eu_pt_1516_new
-  - :outcome_uk_ft_1516_continuing
-  - :outcome_uk_ft_1516_new
-  - :outcome_uk_ft_1617_continuing
-  - :outcome_uk_ft_1617_new
-  - :pt_course_start?
-  :form_needed_for_1?:
-  - :outcome_ccg_expenses
-  - :outcome_dsa_expenses
-  - :outcome_travel
-  - :what_year_full_time?
-  :form_needed_for_2?:
-  - :outcome_dsa_expenses
-  - :what_year_part_time?
-  :pt_course_start?:
-  - :outcome_uk_pt_1415_continuing
-  - :outcome_uk_pt_1415_grant
-  - :outcome_uk_pt_1415_new
-  - :outcome_uk_pt_1516_continuing
-  - :outcome_uk_pt_1516_new
-  - :outcome_uk_ptgc_1516_grant
-  - :outcome_uk_ptgn_1516_grant
-  :type_of_student?:
-  - :form_needed_for_1?
-  - :form_needed_for_2?
-  - :what_year_full_time?
-  - :what_year_part_time?
-  :what_year_full_time?:
-  - :continuing_student?
-  - :outcome_ccg_1516
-  - :outcome_ccg_1617
-  - :outcome_dsa_1516
-  - :outcome_dsa_1617
-  - :outcome_parent_partner_1516
-  - :outcome_parent_partner_1617
-  - :outcome_proof_identity_1516
-  - :outcome_proof_identity_1617
-  :what_year_part_time?:
-  - :continuing_student?
-  - :outcome_dsa_1415_pt
-  - :outcome_dsa_1516_pt
-  - :outcome_proof_identity_1415
-  - :outcome_proof_identity_1516
-towing-rules:
-  :bus_licenceholder?:
-  - :full_entitlement_bus
-  - :how_old_are_you_bus?
-  :car_licence_before_jan_1997?:
-  - :do_you_have_lv_or_bus_towing_entitlement?
-  - :full_entitlement_minibus
-  :date_licence_was_issued?:
-  - :limited_trailer_entitlement
-  - :limited_trailer_entitlement_2013
-  :date_licence_was_issued_msv?:
-  - :full_entitlement_msv
-  - :how_old_are_you_msv_2?
-  :do_you_have_lv_or_bus_towing_entitlement?:
-  - :full_minibus_licence?
-  - :included_entitlement_minibus
-  :existing_large_vehicle_licence?:
-  - :full_cat_c_entitlement
-  - :how_old_are_you_lv?
-  :existing_large_vehicle_towing_entitlements?:
-  - :date_licence_was_issued_msv?
-  - :included_entitlement_msv
-  :existing_towing_entitlements?:
-  - :date_licence_was_issued?
-  - :how_long_entitlements?
-  :full_minibus_licence?:
-  - :how_old_are_you_minibus?
-  - :limited_towing_entitlement_minibus
-  :how_long_entitlements?:
-  - :car_light_vehicle_entitlement
-  - :full_entitlement
-  :how_old_are_you_bus?:
-  - :apply_for_provisional_bus
-  - :not_old_enough_bus
-  :how_old_are_you_lv?:
-  - :apply_for_provisional_lv
-  - :not_old_enough_lv
-  :how_old_are_you_minibus?:
-  - :limited_overall_entitlement_minibus
-  - :not_old_enough_minibus
-  :how_old_are_you_msv?:
-  - :limited_conditional_trailer_entitlement_msv
-  - :limited_trailer_entitlement_msv
-  :how_old_are_you_msv_2?:
-  - :apply_for_provisional_msv
-  - :apply_for_provisional_with_exceptions_msv
-  - :too_young_msv
-  :medium_sized_vehicle_licenceholder?:
-  - :existing_large_vehicle_towing_entitlements?
-  - :how_old_are_you_msv?
-  :towing_vehicle_type?:
-  - :bus_licenceholder?
-  - :car_licence_before_jan_1997?
-  - :existing_large_vehicle_licence?
-  - :existing_towing_entitlements?
-  - :medium_sized_vehicle_licenceholder?
-uk-benefits-abroad:
-  :db_claiming_benefits?:
-  - :db_already_abroad_eea_outcome
-  - :db_already_abroad_other_outcome
-  - :db_going_abroad_eea_outcome
-  - :db_going_abroad_other_outcome
-  :db_how_long_abroad?:
-  - :db_already_abroad_temporary_outcome
-  - :db_going_abroad_temporary_outcome
-  - :which_country?
-  :do_either_of_the_following_apply?:
-  - :child_benefit_entitled_outcome
-  - :child_benefit_not_entitled_outcome
-  :eligible_for_smp?:
-  - :maternity_benefits_eea_entitled_outcome
-  - :maternity_benefits_maternity_allowance_outcome
-  :eligible_for_tax_credits?:
-  - :tax_credits_cross_border_worker_outcome
-  - :tax_credits_crown_servant_outcome
-  - :tax_credits_how_long_abroad?
-  :employer_paying_ni?:
-  - :eligible_for_smp?
-  - :maternity_benefits_not_entitled_outcome
-  - :maternity_benefits_social_security_already_abroad_outcome
-  - :maternity_benefits_social_security_going_abroad_outcome
-  - :ssp_already_abroad_entitled_outcome
-  - :ssp_already_abroad_not_entitled_outcome
-  - :ssp_going_abroad_entitled_outcome
-  - :ssp_going_abroad_not_entitled_outcome
-  :esa_how_long_abroad?:
-  - :esa_already_abroad_under_a_year_medical_outcome
-  - :esa_already_abroad_under_a_year_other_outcome
-  - :esa_going_abroad_under_a_year_medical_outcome
-  - :esa_going_abroad_under_a_year_other_outcome
-  - :which_country?
-  :going_or_already_abroad?:
-  - :which_benefit?
-  :iidb_already_claiming?:
-  - :iidb_maybe_outcome
-  - :which_country?
-  :is_abroad_for_treatment?:
-  - :is_abroad_for_treatment_outcome
-  - :is_work_or_sick_pay?
-  :is_any_of_the_following_apply?:
-  - :is_abroad_for_treatment_outcome
-  - :is_not_eligible_outcome
-  :is_claiming_benefits?:
-  - :is_claiming_benefits_outcome
-  - :is_either_of_the_following?
-  :is_either_of_the_following?:
-  - :is_abroad_for_treatment?
-  - :is_any_of_the_following_apply?
-  :is_how_long_abroad?:
-  - :is_claiming_benefits?
-  - :is_more_than_a_year_outcome
-  - :is_under_a_year_medical_outcome
-  :is_work_or_sick_pay?:
-  - :is_abroad_for_treatment_outcome
-  - :is_not_eligible_outcome
-  :jsa_how_long_abroad?:
-  - :jsa_less_than_a_year_medical_outcome
-  - :jsa_less_than_a_year_other_outcome
-  - :which_country?
-  :tax_credits_children?:
-  - :tax_credits_unlikely_outcome
-  - :which_country?
-  :tax_credits_currently_claiming?:
-  - :tax_credits_eea_entitled_outcome
-  - :tax_credits_unlikely_outcome
-  :tax_credits_how_long_abroad?:
-  - :tax_credits_children?
-  - :tax_credits_why_going_abroad?
-  :tax_credits_why_going_abroad?:
-  - :tax_credits_holiday_outcome
-  - :tax_credits_medical_death_outcome
-  :which_benefit?:
-  - :db_how_long_abroad?
-  - :eligible_for_tax_credits?
-  - :esa_how_long_abroad?
-  - :iidb_already_claiming?
-  - :is_already_abroad_outcome
-  - :is_how_long_abroad?
-  - :jsa_how_long_abroad?
-  - :pension_already_abroad_outcome
-  - :pension_going_abroad_outcome
-  - :which_country?
-  :which_country?:
-  - :bb_already_abroad_eea_outcome
-  - :bb_already_abroad_other_outcome
-  - :bb_already_abroad_ss_outcome
-  - :bb_going_abroad_eea_outcome
-  - :bb_going_abroad_other_outcome
-  - :bb_going_abroad_ss_outcome
-  - :child_benefit_fy_already_abroad_outcome
-  - :child_benefit_fy_going_abroad_outcome
-  - :child_benefit_jtu_outcome
-  - :child_benefit_not_entitled_outcome
-  - :child_benefit_ss_outcome
-  - :db_already_abroad_other_outcome
-  - :db_claiming_benefits?
-  - :db_going_abroad_other_outcome
-  - :do_either_of_the_following_apply?
-  - :employer_paying_ni?
-  - :esa_already_abroad_eea_outcome
-  - :esa_already_abroad_other_outcome
-  - :esa_already_abroad_ss_outcome
-  - :esa_going_abroad_eea_outcome
-  - :esa_going_abroad_other_outcome
-  - :iidb_already_abroad_eea_outcome
-  - :iidb_already_abroad_other_outcome
-  - :iidb_already_abroad_ss_outcome
-  - :iidb_going_abroad_eea_outcome
-  - :iidb_going_abroad_other_outcome
-  - :iidb_going_abroad_ss_outcome
-  - :jsa_eea_already_abroad_outcome
-  - :jsa_eea_going_abroad_outcome
-  - :jsa_not_entitled_outcome
-  - :jsa_social_security_already_abroad_outcome
-  - :jsa_social_security_going_abroad_outcome
-  - :tax_credits_currently_claiming?
-  - :tax_credits_unlikely_outcome
-  - :wfp_eea_eligible_outcome
-  - :wfp_going_abroad_outcome
-  - :wfp_not_eligible_outcome
-  - :working_for_a_uk_employer?
-  - :working_for_uk_employer_ssp?
-  :working_for_a_uk_employer?:
-  - :eligible_for_smp?
-  - :maternity_benefits_maternity_allowance_outcome
-  :working_for_uk_employer_ssp?:
-  - :ssp_already_abroad_entitled_outcome
-  - :ssp_already_abroad_not_entitled_outcome
-  - :ssp_going_abroad_entitled_outcome
-  - :ssp_going_abroad_not_entitled_outcome
-vat-payment-deadlines:
-  :how_do_you_want_to_pay?:
-  - :result_bacs_direct_credit
-  - :result_bank_giro
-  - :result_chaps
-  - :result_cheque
-  - :result_direct_debit
-  - :result_online_debit_credit_card
-  - :result_online_telephone_banking
-  :when_does_your_vat_accounting_period_end?:
-  - :how_do_you_want_to_pay?

From 718794ea62eb662367a7f4b7f86564ff0c8bda32 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 16:57:46 +0100
Subject: [PATCH 43/44] Remove script to generate permitted next nodes for all
 flows

This script has served its purpose and can be removed.
---
 script/generate-permitted-next-nodes-for-all-flows.rb | 11 -----------
 1 file changed, 11 deletions(-)
 delete mode 100644 script/generate-permitted-next-nodes-for-all-flows.rb

diff --git a/script/generate-permitted-next-nodes-for-all-flows.rb b/script/generate-permitted-next-nodes-for-all-flows.rb
deleted file mode 100644
index 77134376d64..00000000000
--- a/script/generate-permitted-next-nodes-for-all-flows.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-flows = SmartAnswer::FlowRegistry.instance.flows
-data = flows.sort_by(&:name).inject({}) do |hash, flow|
-  hash[flow.name] = flow.questions.sort_by(&:name).inject({}) do |q_vs_pnn, question|
-    q_vs_pnn[question.name] = question.permitted_next_nodes.sort
-    q_vs_pnn
-  end
-  hash
-end
-
-path = Rails.root.join('test', 'data', 'permitted-next-nodes.yml')
-File.write(path, data.to_yaml)

From e3813566d030375c972355e86807a2d21b920d29 Mon Sep 17 00:00:00 2001
From: James Mead <james@floehopper.org>
Date: Mon, 14 Mar 2016 17:26:17 +0100
Subject: [PATCH 44/44] Fix Lint/UnusedBlockArgument Rubocop violation

---
 lib/smart_answer_flows/landlord-immigration-check.rb | 2 +-
 test/data/landlord-immigration-check-files.yml       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/smart_answer_flows/landlord-immigration-check.rb b/lib/smart_answer_flows/landlord-immigration-check.rb
index d0095b82b07..a904fd076da 100644
--- a/lib/smart_answer_flows/landlord-immigration-check.rb
+++ b/lib/smart_answer_flows/landlord-immigration-check.rb
@@ -11,7 +11,7 @@ def define
           Calculators::LandlordImmigrationCheckCalculator.new(response)
         end
 
-        next_node(permitted: :auto) do |response|
+        next_node(permitted: :auto) do
           if calculator.included_country?
             question :main_home?
           else
diff --git a/test/data/landlord-immigration-check-files.yml b/test/data/landlord-immigration-check-files.yml
index 144e6f937cc..4ef18fd4fd0 100644
--- a/test/data/landlord-immigration-check-files.yml
+++ b/test/data/landlord-immigration-check-files.yml
@@ -1,5 +1,5 @@
 ---
-lib/smart_answer_flows/landlord-immigration-check.rb: 484295a5969844e7a17ee3b6c4b8e326
+lib/smart_answer_flows/landlord-immigration-check.rb: d5faad347f31d56b96893f9114c9797c
 test/data/landlord-immigration-check-questions-and-responses.yml: d4b485131540c40211b26a50e071032d
 test/data/landlord-immigration-check-responses-and-expected-results.yml: 7982d80c9851bfa7e55dbee4661e70bc
 lib/smart_answer_flows/landlord-immigration-check/landlord_immigration_check.govspeak.erb: 60507bfc657cf13a750b258017453743