diff --git a/app/services/navigation.rb b/app/services/navigation.rb index 4f08d6c5a..564422df2 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -17,7 +17,9 @@ def next private def next_question_id - if skip_income? || skip_income_range? || skip_income_amount? + if skip_to_claim_step? + :claim + elsif skip_income_steps? probate_or_claim elsif skip_savings_and_investment_extra? :benefit @@ -31,6 +33,10 @@ def skip_income? @current_question == :benefit && @online_application.benefits? end + def skip_probate? + @current_question == :income_amount + end + def skip_income_range? (@current_question == :income_kind && @online_application.income&.zero?) end @@ -41,6 +47,15 @@ def skip_income_amount? @online_application.income_max_threshold_exceeded) end + def skip_income_steps? + skip_income? || skip_income_range? || skip_income_amount? + end + + def skip_to_claim_step? + ProbateFeesSwitch.disable_probate_fees? && + (skip_income_steps? || skip_probate?) + end + def skip_savings_and_investment_extra? @current_question == :savings_and_investment && !@online_application.savings_and_investment_extra_required? diff --git a/app/views/questions/forms/_form_name.html.slim b/app/views/questions/forms/_form_name.html.slim index 9dfe7c98c..20596c5af 100644 --- a/app/views/questions/forms/_form_name.html.slim +++ b/app/views/questions/forms/_form_name.html.slim @@ -14,7 +14,7 @@ = f.check_box :et = t('et', scope: @form.i18n_scope) -- if ProbateFeesSwitch.use_probate_fees_changes? +- if ProbateFeesSwitch.disable_probate_fees? .form-group class=('error' if @form.errors[:probate].any?) - if @form.errors[:probate].any? span.error-message#probate = @form.errors[:probate].join(' ') diff --git a/app/views/summaries/show.html.slim b/app/views/summaries/show.html.slim index 8a7d2830f..2b26e4002 100644 --- a/app/views/summaries/show.html.slim +++ b/app/views/summaries/show.html.slim @@ -94,32 +94,33 @@ table.summary span.visuallyhidden |   =t('income', scope: 'summary.labels').downcase - -if @summary.probate - tr - th scope="row" = t('deceased_name', scope: 'summary.labels') - td =@summary.deceased_name - td.right= link_to question_path(:probate) do - =t('summary.change') - span.visuallyhidden - |   - =t('deceased_name', scope: 'summary.labels').downcase - tr - th scope="row" = t('date_of_death', scope: 'summary.labels') - td =@summary.date_of_death - td.right= link_to question_path(:probate) do - =t('summary.change') - span.visuallyhidden - |   - =t('date_of_death', scope: 'summary.labels').downcase - -elsif !@summary.et? - tr - th scope="row" =t('probate', scope: 'summary.labels') - td =t("probate_case_#{@summary.probate}", scope: 'summary') - td.right= link_to question_path(:probate) do - =t('summary.change') - span.visuallyhidden - |   - =t('probate', scope: 'summary.labels').downcase + -unless ProbateFeesSwitch.disable_probate_fees? + - if @summary.probate + tr + th scope="row" = t('deceased_name', scope: 'summary.labels') + td =@summary.deceased_name + td.right= link_to question_path(:probate) do + =t('summary.change') + span.visuallyhidden + |   + =t('deceased_name', scope: 'summary.labels').downcase + tr + th scope="row" = t('date_of_death', scope: 'summary.labels') + td =@summary.date_of_death + td.right= link_to question_path(:probate) do + =t('summary.change') + span.visuallyhidden + |   + =t('date_of_death', scope: 'summary.labels').downcase + -elsif !@summary.et? + tr + th scope="row" =t('probate', scope: 'summary.labels') + td =t("probate_case_#{@summary.probate}", scope: 'summary') + td.right= link_to question_path(:probate) do + =t('summary.change') + span.visuallyhidden + |   + =t('probate', scope: 'summary.labels').downcase tr th scope="row" =t('claim', scope: 'summary.labels') td =t("claim_number_#{@summary.case_number?}", scope: 'summary') diff --git a/lib/probate_fees_switch.rb b/lib/probate_fees_switch.rb index afe2e5db9..3cf8dd8ef 100644 --- a/lib/probate_fees_switch.rb +++ b/lib/probate_fees_switch.rb @@ -1,5 +1,5 @@ class ProbateFeesSwitch - def self.use_probate_fees_changes? + def self.disable_probate_fees? Time.zone.now >= Settings.probate_fees.release_date end end diff --git a/spec/features/apply_for_help_with_fees_spec.rb b/spec/features/apply_for_help_with_fees_spec.rb index ab03bafe2..170e35988 100644 --- a/spec/features/apply_for_help_with_fees_spec.rb +++ b/spec/features/apply_for_help_with_fees_spec.rb @@ -19,7 +19,11 @@ def find_finish_button RSpec.feature 'As a user' do - after { I18n.locale = :en } + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after do + Timecop.return + I18n.locale = :en + end I18n.available_locales.each do |locale| context "using the #{locale.upcase} language" do diff --git a/spec/features/pages/income_question_spec.rb b/spec/features/pages/income_question_spec.rb index 99c6d4f19..2b9b3751b 100644 --- a/spec/features/pages/income_question_spec.rb +++ b/spec/features/pages/income_question_spec.rb @@ -8,10 +8,13 @@ context 'completing the form correctly' do context 'when "no income" selected' do before do + Timecop.freeze(a_day_before_disable_probate_fees) check :income_kind_applicant_13 click_button 'Continue' end + after { Timecop.return } + scenario 'I expect to be routed to the "probate" page' do expect(page).to have_content 'Are you paying a fee for a probate case?' end @@ -73,7 +76,12 @@ end context 'when accessing the "income_amount" page for "Help with fees"' do - before { given_user_answers_questions_up_to(:income_amount) } + before do + Timecop.freeze(a_day_before_disable_probate_fees) + given_user_answers_questions_up_to(:income_amount) + end + + after { Timecop.return } context 'completing the form correctly' do before do diff --git a/spec/features/pages/probate_question_spec.rb b/spec/features/pages/probate_question_spec.rb index 9943b5011..86b6322dd 100644 --- a/spec/features/pages/probate_question_spec.rb +++ b/spec/features/pages/probate_question_spec.rb @@ -2,6 +2,9 @@ require 'rails_helper' RSpec.feature 'As a user' do + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after { Timecop.return } + context 'when accessing the "probate" page for "Help with fees"' do before { given_user_answers_questions_up_to(:probate) } diff --git a/spec/features/pages/summary_spec.rb b/spec/features/pages/summary_spec.rb index bd4503480..0daba6b94 100644 --- a/spec/features/pages/summary_spec.rb +++ b/spec/features/pages/summary_spec.rb @@ -34,35 +34,40 @@ end end - context 'after answering yes to the probate question' do - before do - given_user_answers_questions_up_to(:probate) - choose 'probate_kase_true' - fill_in :probate_deceased_name, with: 'Foo' - fill_in :probate_date_of_death, with: Time.zone.today - 1.month - click_button 'Continue' - page.visit '/summary' - end + context 'when probate fess is still active' do + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after { Timecop.return } - scenario 'I expect to see my answers' do - expect(page).to have_no_content 'Probate case' - expect(page).to have_content 'Name of deceasedFooChange' - expect(page).to have_content "Date of death#{(Time.zone.today - 1.month).strftime(Date::DATE_FORMATS[:default])}Change" - end - end + context 'after answering yes to the probate question' do + before do + given_user_answers_questions_up_to(:probate) + choose 'probate_kase_true' + fill_in :probate_deceased_name, with: 'Foo' + fill_in :probate_date_of_death, with: Time.zone.today - 1.month + click_button 'Continue' + page.visit '/summary' + end - context 'after answering no to the probate question' do - before do - given_user_answers_questions_up_to(:probate) - choose 'probate_kase_false' - click_button 'Continue' - page.visit '/summary' + scenario 'I expect to see my answers' do + expect(page).to have_no_content 'Probate case' + expect(page).to have_content 'Name of deceasedFooChange' + expect(page).to have_content "Date of death#{(Time.zone.today - 1.month).strftime(Date::DATE_FORMATS[:default])}Change" + end end - scenario 'I do not expect to see the probate sub headers' do - expect(page).to have_content 'Probate case' - expect(page).to have_no_content 'Name of deceased' - expect(page).to have_no_content 'Date of death' + context 'after answering no to the probate question' do + before do + given_user_answers_questions_up_to(:probate) + choose 'probate_kase_false' + click_button 'Continue' + page.visit '/summary' + end + + scenario 'I do not expect to see the probate sub headers' do + expect(page).to have_content 'Probate case' + expect(page).to have_no_content 'Name of deceased' + expect(page).to have_no_content 'Date of death' + end end end @@ -90,23 +95,52 @@ end end - scenario 'the change links take me to the correct page' do - given_user_provides_all_data - visit '/summary' - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:form_name)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:marital_status)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:savings_and_investment)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:benefit)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dependent)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:income_kind)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:fee)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:probate)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:claim)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dob)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:national_insurance)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:personal_detail)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:applicant_address)}')]" - expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:contact)}')]" + context 'when probate is still active' do + scenario 'the change links take me to the correct page' do + Timecop.freeze(a_day_before_disable_probate_fees) do + given_user_provides_all_data + visit '/summary' + end + + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:form_name)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:marital_status)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:savings_and_investment)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:benefit)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dependent)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:income_kind)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:fee)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:probate)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:claim)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dob)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:national_insurance)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:personal_detail)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:applicant_address)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:contact)}')]" + end + end + + context 'when probate is deactivated' do + scenario 'the change links take me to the correct page' do + Timecop.freeze(probate_fees_release_date) do + given_user_provides_all_data + visit '/summary' + end + + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:form_name)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:marital_status)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:savings_and_investment)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:benefit)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dependent)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:income_kind)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:fee)}')]" + expect(page).not_to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:probate)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:claim)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:dob)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:national_insurance)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:personal_detail)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:applicant_address)}')]" + expect(page).to have_xpath "//a[starts-with(text(), 'Change')][starts-with(@href,'#{question_path(:contact)}')]" + end end end end diff --git a/spec/features/pages/user_can_apply_for_et_case_spec.rb b/spec/features/pages/user_can_apply_for_et_case_spec.rb index eaeb51ba4..ec7175977 100644 --- a/spec/features/pages/user_can_apply_for_et_case_spec.rb +++ b/spec/features/pages/user_can_apply_for_et_case_spec.rb @@ -4,11 +4,14 @@ RSpec.feature 'As a user' do context 'I want to be able to apply for help with fees for my ET case' do before do + Timecop.freeze { a_day_before_disable_probate_fees } given_the_submission_service_is_available when_they_apply_for_help_with_et_case expect(page).to have_content 'Your application for help with fees is not finished yet' end + after { Timecop.return } + scenario 'I expect to see instructions how to finish application' do expect(page).to have_content 'You must email or post this help with fees reference number HWF-ABC123 along with your employment tribunal claim number to the relevant Employment Tribunal Central Office.' expect(page).to have_content 'Email or send your letter to the relevant Employment Tribunal Central Office detailed below.' diff --git a/spec/lib/probate_fees_switch_spec.rb b/spec/lib/probate_fees_switch_spec.rb index a4d714ea4..9051e6c02 100644 --- a/spec/lib/probate_fees_switch_spec.rb +++ b/spec/lib/probate_fees_switch_spec.rb @@ -1,10 +1,10 @@ RSpec.describe ProbateFeesSwitch do subject { described_class } - describe '#use_probate_fees_changes?' do + describe '#disable_probate_fees?' do subject do Timecop.freeze(current_time) do - described_class.use_probate_fees_changes? + described_class.disable_probate_fees? end end @@ -15,7 +15,7 @@ end context 'when called before the set date' do - let(:current_time) { probate_fees_release_date - 1.day } + let(:current_time) { a_day_before_disable_probate_fees } it { is_expected.to be false } end diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index ab1175674..6107878bb 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -26,7 +26,9 @@ let(:current_question) { current_question } it "routes to #{next_question} question" do - is_expected.to eql(question_path(next_question, locale: :en)) + Timecop.freeze(a_day_before_disable_probate_fees) do + is_expected.to eql(question_path(next_question, locale: :en)) + end end end end @@ -36,26 +38,43 @@ let(:current_question) { :benefit } let(:form_name) { nil } - context 'when the application is benefit one' do - let(:benefits) { true } + context 'when probate fees is deactivated' do + context 'when the application is benefit one' do + let(:benefits) { true } - it 'routes to the probate question (skips dependent and income)' do - is_expected.to eql(question_path(:probate, locale: :en)) + it 'routes to the claim question (skips dependent, income and probate)' do + Timecop.freeze(probate_fees_release_date) do + is_expected.to eql(question_path(:claim, locale: :en)) + end + end end + end - context 'when the application is for ET' do - let(:form_name) { 'ET1' } - it 'routes to the claim question (skips dependent and income)' do - is_expected.to eql(question_path(:claim, locale: :en)) + context 'when probate fees is still active' do + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after { Timecop.return } + + context 'when the application is benefit one' do + let(:benefits) { true } + + it 'routes to the probate question (skips dependent and income)' do + is_expected.to eql(question_path(:probate, locale: :en)) + end + + context 'when the application is for ET' do + let(:form_name) { 'ET1' } + it 'routes to the claim question (skips dependent and income)' do + is_expected.to eql(question_path(:claim, locale: :en)) + end end end - end - context 'when the application is not a benefit one' do - let(:benefits) { false } + context 'when the application is not a benefit one' do + let(:benefits) { false } - it 'routes to the dependent question' do - is_expected.to eql(question_path(:dependent, locale: :en)) + it 'routes to the dependent question' do + is_expected.to eql(question_path(:dependent, locale: :en)) + end end end end @@ -91,17 +110,34 @@ context 'for income_kind question' do let(:current_question) { :income_kind } - context 'when the application is 0 income - "no income" selected' do - let(:online_application) { build :online_application, :no_income } + context 'when probate fees is deactived' do + context 'when the application is 0 income - "no income" selected' do + let(:online_application) { build :online_application, :no_income } - it 'routes to the probate question' do - is_expected.to eql(question_path(:probate, locale: :en)) + it 'routes to the claims question' do + Timecop.freeze(probate_fees_release_date) do + is_expected.to eql(question_path(:claim, locale: :en)) + end + end end end - context 'when the application is not 0 income - some income sources selected' do - it 'routes to the income_range question' do - is_expected.to eql(question_path(:income_range, locale: :en)) + context 'when probate fees is still active' do + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after { Timecop.return } + + context 'when the application is 0 income - "no income" selected' do + let(:online_application) { build :online_application, :no_income } + + it 'routes to the probate question' do + is_expected.to eql(question_path(:probate, locale: :en)) + end + end + + context 'when the application is not 0 income - some income sources selected' do + it 'routes to the income_range question' do + is_expected.to eql(question_path(:income_range, locale: :en)) + end end end end @@ -109,27 +145,53 @@ context 'for income_range question' do let(:current_question) { :income_range } - context 'when the application is between thresholds' do - let(:online_application) { build :online_application, :income_between_thresholds } + context ' when probate fess is deactivated' do + before { Timecop.freeze(probate_fees_release_date) } + after { Timecop.return } - it 'routes to the income_amount question' do - is_expected.to eql(question_path(:income_amount, locale: :en)) + context 'when the application is below thresholds' do + let(:online_application) { build :online_application, :income_below_thresholds } + + it 'routes to the claim question' do + is_expected.to eql(question_path(:claim, locale: :en)) + end end - end - context 'when the application is below thresholds' do - let(:online_application) { build :online_application, :income_below_thresholds } + context 'when the application is above thresholds' do + let(:online_application) { build :online_application, :income_above_thresholds } - it 'routes to the probate question' do - is_expected.to eql(question_path(:probate, locale: :en)) + it 'routes to the claim question' do + is_expected.to eql(question_path(:claim, locale: :en)) + end end end - context 'when the application is above thresholds' do - let(:online_application) { build :online_application, :income_above_thresholds } + context 'when probate fees is still active' do + before { Timecop.freeze(a_day_before_disable_probate_fees) } + after { Timecop.return } + + context 'when the application is between thresholds' do + let(:online_application) { build :online_application, :income_between_thresholds } + + it 'routes to the income_amount question' do + is_expected.to eql(question_path(:income_amount, locale: :en)) + end + end + + context 'when the application is below thresholds' do + let(:online_application) { build :online_application, :income_below_thresholds } + + it 'routes to the probate question' do + is_expected.to eql(question_path(:probate, locale: :en)) + end + end - it 'routes to the probate question' do - is_expected.to eql(question_path(:probate, locale: :en)) + context 'when the application is above thresholds' do + let(:online_application) { build :online_application, :income_above_thresholds } + + it 'routes to the probate question' do + is_expected.to eql(question_path(:probate, locale: :en)) + end end end end diff --git a/spec/support/feature_steps.rb b/spec/support/feature_steps.rb index 72b968422..c4c4138a3 100644 --- a/spec/support/feature_steps.rb +++ b/spec/support/feature_steps.rb @@ -5,6 +5,8 @@ def given_user_answers_questions_up_to(question) click_link_or_button 'Apply now' QuestionFormFactory::IDS.take_while { |id| id != question }.each do |id| + next if ProbateFeesSwitch.disable_probate_fees? && id == :probate + send("fill_#{id}") end end @@ -27,7 +29,7 @@ def given_user_provides_all_data_for_refund fill_income_kind fill_income_range fill_income_amount - fill_probate + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob @@ -48,7 +50,7 @@ def given_user_provides_all_data_for_below_threshold_income fill_dependent fill_income_kind fill_income_range(below: true) - fill_probate + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob @@ -66,7 +68,7 @@ def given_user_provides_all_data_for_benefit fill_savings_and_investment fill_savings_and_investment_extra fill_benefit(true) - fill_probate + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob diff --git a/spec/support/probate_fees_switchover_helper.rb b/spec/support/probate_fees_switchover_helper.rb index ccb6b767c..940795d4c 100644 --- a/spec/support/probate_fees_switchover_helper.rb +++ b/spec/support/probate_fees_switchover_helper.rb @@ -5,3 +5,7 @@ def probate_fees_release_date Time.zone.parse(Settings.probate_fees.release_date) end end + +def a_day_before_disable_probate_fees + probate_fees_release_date - 1.day +end