From dad57c7438e6da25657207063ae9372bebe58494 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 27 Mar 2017 20:58:38 +0100 Subject: [PATCH 01/11] skip probate page on step 6 for users who choose they receive benefits --- app/services/navigation.rb | 4 ++- spec/services/navigation_spec.rb | 42 +++++++++++++++++++++----------- spec/support/feature_steps.rb | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index 4f08d6c5a..eb5519436 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 ProbateFeesSwitch.use_probate_fees_changes? && skip_income? + :claim + elsif skip_income? || skip_income_range? || skip_income_amount? probate_or_claim elsif skip_savings_and_investment_extra? :benefit diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index ab1175674..61731523d 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -36,26 +36,40 @@ let(:current_question) { :benefit } let(:form_name) { nil } - 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)) + 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 + Timecop.freeze(Date.parse('2017-05-01')) do + is_expected.to eql(question_path(:claim, locale: :en)) + end + end end + end + + context 'when probate fees is still active' do + context 'when the application is benefit one' do + let(:benefits) { true } - 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)) + 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 diff --git a/spec/support/feature_steps.rb b/spec/support/feature_steps.rb index 72b968422..532c47d1c 100644 --- a/spec/support/feature_steps.rb +++ b/spec/support/feature_steps.rb @@ -66,7 +66,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.use_probate_fees_changes? fill_claim fill_national_insurance fill_dob From d9b29ac10b52b5ccc81e917e45de657d57b71884 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 29 Mar 2017 09:33:32 +0100 Subject: [PATCH 02/11] fix navigation specs --- spec/services/navigation_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index 61731523d..96985270e 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -41,7 +41,7 @@ let(:benefits) { true } it 'routes to the probate question (skips dependent and income)' do - Timecop.freeze(Date.parse('2017-05-01')) do + Timecop.freeze(probate_fees_release_date) do is_expected.to eql(question_path(:claim, locale: :en)) end end @@ -49,6 +49,8 @@ end context 'when probate fees is still active' do + before { Timecop.freeze(probate_fees_release_date - 1.day) } + after { Timecop.return } context 'when the application is benefit one' do let(:benefits) { true } From 886c709da8acebd3d8af20e2695621c6a9a5fdd6 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 29 Mar 2017 09:39:05 +0100 Subject: [PATCH 03/11] reduce complexity in navigation class --- app/services/navigation.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index eb5519436..be1b8b591 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -17,9 +17,9 @@ def next private def next_question_id - if ProbateFeesSwitch.use_probate_fees_changes? && skip_income? + if skip_probate_step? :claim - elsif skip_income? || skip_income_range? || skip_income_amount? + elsif skip_income_steps? probate_or_claim elsif skip_savings_and_investment_extra? :benefit @@ -43,6 +43,14 @@ 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_probate_step? + ProbateFeesSwitch.use_probate_fees_changes? && skip_income? + end + def skip_savings_and_investment_extra? @current_question == :savings_and_investment && !@online_application.savings_and_investment_extra_required? From d174e775f80da22bd852b38741be6f1f91742426 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 29 Mar 2017 10:42:48 +0100 Subject: [PATCH 04/11] update spec description --- spec/services/navigation_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index 96985270e..f92640102 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -40,7 +40,7 @@ context 'when the application is benefit one' do let(:benefits) { true } - it 'routes to the probate question (skips dependent and income)' do + 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 @@ -51,6 +51,7 @@ context 'when probate fees is still active' do before { Timecop.freeze(probate_fees_release_date - 1.day) } after { Timecop.return } + context 'when the application is benefit one' do let(:benefits) { true } From e2d07a3ed3d4cea18010edcbcb45a7066ea0c07c Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 29 Mar 2017 12:01:05 +0100 Subject: [PATCH 05/11] skip probate page when user chooses no income on step 8 --- app/services/navigation.rb | 3 +- spec/features/pages/income_question_spec.rb | 3 ++ spec/services/navigation_spec.rb | 31 ++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index be1b8b591..d6d8f5bb6 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -48,7 +48,8 @@ def skip_income_steps? end def skip_probate_step? - ProbateFeesSwitch.use_probate_fees_changes? && skip_income? + ProbateFeesSwitch.use_probate_fees_changes? && skip_income? || + ProbateFeesSwitch.use_probate_fees_changes? && skip_income_range? end def skip_savings_and_investment_extra? diff --git a/spec/features/pages/income_question_spec.rb b/spec/features/pages/income_question_spec.rb index 99c6d4f19..98cfd2bcf 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(probate_fees_release_date - 1.day) 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 diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index f92640102..9935be968 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -108,17 +108,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(probate_fees_release_date - 1.day) } + 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 From e79b3955623df74292e343027590bb29e04360b9 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 29 Mar 2017 12:38:49 +0100 Subject: [PATCH 06/11] skip probate page when users choose less or more income on step 9 --- app/services/navigation.rb | 3 +- spec/services/navigation_spec.rb | 52 ++++++++++++++++++++++++-------- spec/support/feature_steps.rb | 2 +- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index d6d8f5bb6..481f9919c 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -49,7 +49,8 @@ def skip_income_steps? def skip_probate_step? ProbateFeesSwitch.use_probate_fees_changes? && skip_income? || - ProbateFeesSwitch.use_probate_fees_changes? && skip_income_range? + ProbateFeesSwitch.use_probate_fees_changes? && skip_income_range? || + ProbateFeesSwitch.use_probate_fees_changes? && skip_income_amount? end def skip_savings_and_investment_extra? diff --git a/spec/services/navigation_spec.rb b/spec/services/navigation_spec.rb index 9935be968..a4b357f1d 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -143,27 +143,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 } + + context 'when the application is below thresholds' do + let(:online_application) { build :online_application, :income_below_thresholds } - it 'routes to the income_amount question' do - is_expected.to eql(question_path(:income_amount, 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 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(probate_fees_release_date - 1.day) } + 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)) + it 'routes to the probate question' do + is_expected.to eql(question_path(:probate, locale: :en)) + end + end + + 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 532c47d1c..120db6c04 100644 --- a/spec/support/feature_steps.rb +++ b/spec/support/feature_steps.rb @@ -48,7 +48,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.use_probate_fees_changes? fill_claim fill_national_insurance fill_dob From c95124d2b4406c59c83195524b7e454654b8f171 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Fri, 31 Mar 2017 16:42:41 +0100 Subject: [PATCH 07/11] skip entirely the probate step --- app/services/navigation.rb | 13 ++++++++----- spec/support/feature_steps.rb | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index 481f9919c..72c5bb92e 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -17,7 +17,7 @@ def next private def next_question_id - if skip_probate_step? + if skip_to_claim_step? :claim elsif skip_income_steps? probate_or_claim @@ -33,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 @@ -47,10 +51,9 @@ def skip_income_steps? skip_income? || skip_income_range? || skip_income_amount? end - def skip_probate_step? - ProbateFeesSwitch.use_probate_fees_changes? && skip_income? || - ProbateFeesSwitch.use_probate_fees_changes? && skip_income_range? || - ProbateFeesSwitch.use_probate_fees_changes? && skip_income_amount? + def skip_to_claim_step? + ProbateFeesSwitch.use_probate_fees_changes? && + (skip_income_steps? || skip_probate?) end def skip_savings_and_investment_extra? diff --git a/spec/support/feature_steps.rb b/spec/support/feature_steps.rb index 120db6c04..4c98241ff 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.use_probate_fees_changes? && 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.use_probate_fees_changes? fill_claim fill_national_insurance fill_dob From f8e9e30410092e25f76f0559e3dfef6af5602f0f Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Fri, 31 Mar 2017 16:42:56 +0100 Subject: [PATCH 08/11] hide probate from the summary page --- app/views/summaries/show.html.slim | 53 +++++++------ spec/features/pages/summary_spec.rb | 118 ++++++++++++++++++---------- 2 files changed, 103 insertions(+), 68 deletions(-) diff --git a/app/views/summaries/show.html.slim b/app/views/summaries/show.html.slim index 8a7d2830f..d6b4c646f 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.use_probate_fees_changes? + - 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/spec/features/pages/summary_spec.rb b/spec/features/pages/summary_spec.rb index bd4503480..98c947873 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(probate_fees_release_date - 1.day) } + 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(probate_fees_release_date - 1.day) 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 From f66d7db814f0ec9bfcc8d46182ed5dd131edb3a8 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 3 Apr 2017 10:36:21 +0100 Subject: [PATCH 09/11] fix failing specs related to probate changes --- spec/features/apply_for_help_with_fees_spec.rb | 6 +++++- spec/features/pages/income_question_spec.rb | 7 ++++++- spec/features/pages/probate_question_spec.rb | 3 +++ spec/features/pages/user_can_apply_for_et_case_spec.rb | 3 +++ spec/services/navigation_spec.rb | 4 +++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/features/apply_for_help_with_fees_spec.rb b/spec/features/apply_for_help_with_fees_spec.rb index ab03bafe2..9c691ba4c 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(probate_fees_release_date - 1.day) } + 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 98cfd2bcf..c7e6ee7bc 100644 --- a/spec/features/pages/income_question_spec.rb +++ b/spec/features/pages/income_question_spec.rb @@ -76,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(probate_fees_release_date - 1.day) + 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..80e469917 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(probate_fees_release_date - 1.day) } + 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/user_can_apply_for_et_case_spec.rb b/spec/features/pages/user_can_apply_for_et_case_spec.rb index eaeb51ba4..05066e025 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 { probate_fees_release_date - 1.day } 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/services/navigation_spec.rb b/spec/services/navigation_spec.rb index a4b357f1d..f5f015227 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(probate_fees_release_date - 1.day) do + is_expected.to eql(question_path(next_question, locale: :en)) + end end end end From a8da5eb2d2c109c0ed150b8ec3b0cfb8259ef870 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 3 Apr 2017 11:32:22 +0100 Subject: [PATCH 10/11] use a spec help method for the day before the probate release --- spec/features/apply_for_help_with_fees_spec.rb | 2 +- spec/features/pages/income_question_spec.rb | 4 ++-- spec/features/pages/probate_question_spec.rb | 2 +- spec/features/pages/summary_spec.rb | 4 ++-- spec/features/pages/user_can_apply_for_et_case_spec.rb | 2 +- spec/lib/probate_fees_switch_spec.rb | 2 +- spec/services/navigation_spec.rb | 8 ++++---- spec/support/probate_fees_switchover_helper.rb | 4 ++++ 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/spec/features/apply_for_help_with_fees_spec.rb b/spec/features/apply_for_help_with_fees_spec.rb index 9c691ba4c..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,7 @@ def find_finish_button RSpec.feature 'As a user' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after do Timecop.return I18n.locale = :en diff --git a/spec/features/pages/income_question_spec.rb b/spec/features/pages/income_question_spec.rb index c7e6ee7bc..2b9b3751b 100644 --- a/spec/features/pages/income_question_spec.rb +++ b/spec/features/pages/income_question_spec.rb @@ -8,7 +8,7 @@ context 'completing the form correctly' do context 'when "no income" selected' do before do - Timecop.freeze(probate_fees_release_date - 1.day) + Timecop.freeze(a_day_before_disable_probate_fees) check :income_kind_applicant_13 click_button 'Continue' end @@ -77,7 +77,7 @@ context 'when accessing the "income_amount" page for "Help with fees"' do before do - Timecop.freeze(probate_fees_release_date - 1.day) + Timecop.freeze(a_day_before_disable_probate_fees) given_user_answers_questions_up_to(:income_amount) end diff --git a/spec/features/pages/probate_question_spec.rb b/spec/features/pages/probate_question_spec.rb index 80e469917..86b6322dd 100644 --- a/spec/features/pages/probate_question_spec.rb +++ b/spec/features/pages/probate_question_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.feature 'As a user' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after { Timecop.return } context 'when accessing the "probate" page for "Help with fees"' do diff --git a/spec/features/pages/summary_spec.rb b/spec/features/pages/summary_spec.rb index 98c947873..0daba6b94 100644 --- a/spec/features/pages/summary_spec.rb +++ b/spec/features/pages/summary_spec.rb @@ -35,7 +35,7 @@ end context 'when probate fess is still active' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after { Timecop.return } context 'after answering yes to the probate question' do @@ -97,7 +97,7 @@ context 'when probate is still active' do scenario 'the change links take me to the correct page' do - Timecop.freeze(probate_fees_release_date - 1.day) do + Timecop.freeze(a_day_before_disable_probate_fees) do given_user_provides_all_data visit '/summary' 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 05066e025..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,7 +4,7 @@ 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 { probate_fees_release_date - 1.day } + 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' diff --git a/spec/lib/probate_fees_switch_spec.rb b/spec/lib/probate_fees_switch_spec.rb index a4d714ea4..3861480e2 100644 --- a/spec/lib/probate_fees_switch_spec.rb +++ b/spec/lib/probate_fees_switch_spec.rb @@ -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 f5f015227..6107878bb 100644 --- a/spec/services/navigation_spec.rb +++ b/spec/services/navigation_spec.rb @@ -26,7 +26,7 @@ let(:current_question) { current_question } it "routes to #{next_question} question" do - Timecop.freeze(probate_fees_release_date - 1.day) do + Timecop.freeze(a_day_before_disable_probate_fees) do is_expected.to eql(question_path(next_question, locale: :en)) end end @@ -51,7 +51,7 @@ end context 'when probate fees is still active' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after { Timecop.return } context 'when the application is benefit one' do @@ -123,7 +123,7 @@ end context 'when probate fees is still active' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after { Timecop.return } context 'when the application is 0 income - "no income" selected' do @@ -167,7 +167,7 @@ end context 'when probate fees is still active' do - before { Timecop.freeze(probate_fees_release_date - 1.day) } + before { Timecop.freeze(a_day_before_disable_probate_fees) } after { Timecop.return } context 'when the application is between thresholds' do 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 From 4af438dca259d4968d96f15d98756f47fb966e7d Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 3 Apr 2017 12:36:05 +0100 Subject: [PATCH 11/11] rename probate fees switch class method --- app/services/navigation.rb | 2 +- app/views/questions/forms/_form_name.html.slim | 2 +- app/views/summaries/show.html.slim | 2 +- lib/probate_fees_switch.rb | 2 +- spec/lib/probate_fees_switch_spec.rb | 4 ++-- spec/support/feature_steps.rb | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/services/navigation.rb b/app/services/navigation.rb index 72c5bb92e..564422df2 100644 --- a/app/services/navigation.rb +++ b/app/services/navigation.rb @@ -52,7 +52,7 @@ def skip_income_steps? end def skip_to_claim_step? - ProbateFeesSwitch.use_probate_fees_changes? && + ProbateFeesSwitch.disable_probate_fees? && (skip_income_steps? || skip_probate?) end 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 d6b4c646f..2b26e4002 100644 --- a/app/views/summaries/show.html.slim +++ b/app/views/summaries/show.html.slim @@ -94,7 +94,7 @@ table.summary span.visuallyhidden |   =t('income', scope: 'summary.labels').downcase - -unless ProbateFeesSwitch.use_probate_fees_changes? + -unless ProbateFeesSwitch.disable_probate_fees? - if @summary.probate tr th scope="row" = t('deceased_name', scope: 'summary.labels') 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/lib/probate_fees_switch_spec.rb b/spec/lib/probate_fees_switch_spec.rb index 3861480e2..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 diff --git a/spec/support/feature_steps.rb b/spec/support/feature_steps.rb index 4c98241ff..c4c4138a3 100644 --- a/spec/support/feature_steps.rb +++ b/spec/support/feature_steps.rb @@ -5,7 +5,7 @@ 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.use_probate_fees_changes? && id == :probate + next if ProbateFeesSwitch.disable_probate_fees? && id == :probate send("fill_#{id}") end @@ -29,7 +29,7 @@ def given_user_provides_all_data_for_refund fill_income_kind fill_income_range fill_income_amount - fill_probate unless ProbateFeesSwitch.use_probate_fees_changes? + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob @@ -50,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 unless ProbateFeesSwitch.use_probate_fees_changes? + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob @@ -68,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 unless ProbateFeesSwitch.use_probate_fees_changes? + fill_probate unless ProbateFeesSwitch.disable_probate_fees? fill_claim fill_national_insurance fill_dob