Skip to content

Commit

Permalink
Merge pull request #252 from ministryofjustice/feature/rst-112-disabl…
Browse files Browse the repository at this point in the history
…e-probate-page

Feature/rst 112 disable probate page
  • Loading branch information
leoapost authored Apr 3, 2017
2 parents 797147f + 4af438d commit 9c6d45d
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 113 deletions.
17 changes: 16 additions & 1 deletion app/services/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/views/questions/forms/_form_name.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand Down
53 changes: 27 additions & 26 deletions app/views/summaries/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]?
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 [email protected]?
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')
Expand Down
2 changes: 1 addition & 1 deletion lib/probate_fees_switch.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion spec/features/apply_for_help_with_fees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion spec/features/pages/income_question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/features/pages/probate_question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down
118 changes: 76 additions & 42 deletions spec/features/pages/summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions spec/features/pages/user_can_apply_for_et_case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/probate_fees_switch_spec.rb
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
Loading

0 comments on commit 9c6d45d

Please sign in to comment.