Skip to content

Commit

Permalink
Merge pull request #254 from ministryofjustice/feature/rst-194-probat…
Browse files Browse the repository at this point in the history
…e-warning-message

feature/rst 194 probate warning message
  • Loading branch information
leoapost authored Apr 7, 2017
2 parents 7aac200 + ceb13a1 commit 4799a15
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENV=dev
PROBATE_FEES_RELEASE_DATE=2017-05-01

SUBMISSION_URL=http://localhost:3000
SUBMISSION_TOKEN=this_very_secret_token

Expand Down
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ before_install:
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
- "phantomjs --version"
addons:
apt:
packages:
- libqt4-dev
- xvfb
code_climate:
repo_token: ca58e966ca9664d66925f6837f4b2092de2b5eab7580591e955d3bb8be3b40fa
script:
- bundle exec rubocop
- DISPLAY=localhost:1.0 xvfb-run bundle exec rake spec
- bundle exec rspec
after_success:
- bundle exec codeclimate-test-reporter
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ end

group :test do
gem 'capybara'
gem 'capybara-webkit'
gem 'codeclimate-test-reporter', require: nil
gem 'shoulda-matchers'
gem 'timecop'
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.12.0)
capybara (>= 2.3.0, < 2.13.0)
json
codeclimate-test-reporter (1.0.5)
simplecov
coderay (1.1.1)
Expand Down Expand Up @@ -281,7 +278,6 @@ PLATFORMS

DEPENDENCIES
capybara
capybara-webkit
codeclimate-test-reporter
config
date_validator
Expand Down
18 changes: 0 additions & 18 deletions app/assets/javascripts/modules/form-name.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict';

window.moj.Modules.FormName = {
$continue: $("input.button"),
$et: $("#form_name_et"),
$identifier: $('#form_name_identifier'),
$probate: $("#form_name_probate"),
$probate_warning: $('#probate-warning'),
$unknown: $('#form_name_unknown'),

init: function () {
Expand All @@ -23,10 +19,6 @@ window.moj.Modules.FormName = {
self.identifierKeyUp();
});

self.$probate.on('click', function() {
self.probateClick();
})

self.$unknown.on('click', function() {
self.unknownClick();
});
Expand All @@ -40,16 +32,6 @@ window.moj.Modules.FormName = {
}
},

probateClick: function() {
var self = this;
var is_checked = self.$probate.is(':checked');

self.$continue.attr("disabled", is_checked);
self.$et.attr("disabled", is_checked);
self.$identifier.attr("disabled", is_checked);
self.$unknown.attr("disabled", is_checked);
},

unknownClick: function() {
var self = this;

Expand Down
3 changes: 0 additions & 3 deletions app/models/forms/form_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ class FormName < Base
attribute :identifier, String
attribute :unknown, Boolean
attribute :et, Boolean
attribute :probate, Boolean

validates :identifier, length: { maximum: 49 }
validates :identifier, presence: true, unless: 'unknown? || et?'

validates :probate, acceptance: { accept: false }

private

def export_params
Expand Down
19 changes: 1 addition & 18 deletions app/views/questions/forms/_form_name.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.form-group class=('error' if @form.errors[:identifier].any?)
.form-group class=('error' if @form.errors.any?)
- if @form.errors[:identifier].any?
span.error-message#identifier = @form.errors[:identifier].join(' ')
= f.label :identifier, class: 'form-label'
Expand All @@ -14,23 +14,6 @@
= f.check_box :et
= t('et', scope: @form.i18n_scope)

- 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(' ')
label.block-label for="form_name_probate" data-target='probate-warning'
= f.check_box :probate
= t('probate.label', scope: @form.i18n_scope)

#probate-warning.probate-warning.js-hidden
.form-group
.notice.text
i.icon.icon-important
span.visually-hidden
Warning
strong.bold-small
= t('probate.warning_html', scope: @form.i18n_scope)

.form-group
details
summary =t('details.summary', scope: @form.i18n_scope)
Expand Down
8 changes: 8 additions & 0 deletions app/views/questions/headers/_form_name.html.slim
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
- if ProbateFeesSwitch.disable_probate_fees?
p#probate-warning.notice.text.util_mt-large
i.icon.icon-important
span.visually-hidden
Warning
strong.bold-small
= t('probate_warning_html', scope: @form.i18n_scope)

p =t('example', scope: @form.i18n_scope)
8 changes: 2 additions & 6 deletions config/locales/cy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ cy:
identifier:
blank: Rhowch enw neu rif y ffurflen, neu dewiswch 'Dydw i ddim yn gwybod beth yw enw neu rif y ffurflen'
too_long: Rhaid i enw'r ffurflen fod yn llai na 50 o nodau
probate:
accepted: Nid yw'r cynllun Help i dalu Ffioedd ar gael ar gyfer ceisiadau am brofiant ddim mwy. Dewiswch opsiwn arall os gwelwch yn dda.
forms/help_request:
attributes:
description:
Expand Down Expand Up @@ -413,9 +411,7 @@ cy:
summary: Help gydag enw neu rif y ffurflen
et: Rwyf angen help gyda ffi tribiwnlys cyflogaeth
example: Rhowch rif y ffurflen llys neu dribiwnlys ar gyfer y busnes llys y mae arnoch angen help gydag ef, er enghraifft ffurflen ‘C100’, ‘D8’ neu 'Hysbysiad o Apêl'
probate:
label: Rwyf angen help gyda ffi Profiant
warning_html: 'Nid yw''r Gwasanaeth Help i Dalu Ffioedd ar gael i geisiadau profiant mwyach. Cewch fanylion pellach a gwneud cais am brofiant yma: <a class="external" rel="external" href="https://www.gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation">gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation</a>'
probate_warning_html: Nid yw'r Gwasanaeth Help i Dalu Ffioedd ar gael i geisiadau am brofiant ddim mwy. <a class="external" rel="external" href="https://www.gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation">Dod o hyd i fanylion pellach a gwneud cais am brofiant.</a>
text: Pa ffi llys neu dribiwnlys y mae arnoch angen help gyda hi?
title: Enw neu rif y ffurflen
unknown: Dydw i ddim yn gwybod beth yw enw neu rif y ffurflen
Expand Down Expand Up @@ -591,7 +587,7 @@ cy:
applicant_on_benefits_true: Yn derbyn budd-daliadau cymwys
breadcrumb: Cam 18 o 20
change: Newid
children_false: Nac ydw
children_false: Nac oes
claim_number_false: Nac oes
claim_number_true: Oes
contact_none: Manylion cyswllt heb eu darparu
Expand Down
6 changes: 1 addition & 5 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ en:
identifier:
blank: Enter the form name or number, or select 'I don’t know the form name or number'
too_long: The form name must be less than 50 characters
probate:
accepted: Help with Fees is no longer available for probate applications. Please choose any other option.
forms/help_request:
attributes:
description:
Expand Down Expand Up @@ -414,9 +412,7 @@ en:
summary: Help with form name or number
et: I need help with an employment tribunal fee
example: Enter the court or tribunal form number for the court business you need help with, for example ‘C100’, ‘D8’ or ‘notice to appeal’ form.
probate:
label: I need help with a Probate fee
warning_html: 'Help with Fees is no longer available for probate applications. You can find further details and apply for probate here: <a class="external" rel="external" href="https://www.gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation">gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation</a>'
probate_warning_html: Help with Fees is no longer available for probate applications. <a class="external" rel="external" href="https://www.gov.uk/wills-probate-inheritance/applying-for-a-grant-of-representation">Find further details and apply for probate.</a>
text: What court or tribunal fee do you need help with?
title: Form name or number
unknown: I don’t know the form name or number
Expand Down
42 changes: 11 additions & 31 deletions spec/features/pages/form_name_question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,23 @@
end
end

describe 'help with probate fee option' do
context 'when probate fees are still supported' do
before do
Capybara.current_driver = :webkit
Timecop.freeze(probate_fees_release_date) do
given_user_answers_questions_up_to(:form_name)
end
check 'form_name_probate'
Timecop.freeze(a_day_before_disable_probate_fees)
given_user_answers_questions_up_to(:form_name)
end

context 'selecting the probate fees option' do
scenario 'I expect a warning message to appear' do
expect(page).to have_content('Help with Fees is no longer available for probate applications')
end
after { Timecop.return }

scenario 'I expect the form name, the form options and the continue button to be disabled' do
expect(page).to have_css("#form_name_identifier[disabled='disabled']")
expect(page).to have_css("#form_name_unknown[disabled='disabled']")
expect(page).to have_css("#form_name_et[disabled='disabled']")
expect(page).to have_css("input.button[name='commit'][disabled='disabled']")
expect(page).to have_css("input.button[name='commit'][disabled='disabled']")
end
scenario 'I do not expect the warning message to be displayed' do
expect(page).not_to have_css('#probate-warning')
end
end

context 'deselecting the probate fees option' do
before do
uncheck 'form_name_probate'
end

scenario 'I expect the form name, the form options and the continue button to not be disabled' do
expect(page).not_to have_css("#form_name_identifier[disabled='disabled']")
expect(page).not_to have_css("#form_name_unknown[disabled='disabled']")
expect(page).not_to have_css("#form_name_et[disabled='disabled']")
expect(page).not_to have_css("input.button[name='commit'][disabled='disabled']")
end

scenario 'I expect the warning message to disappear' do
expect(page).not_to have_content('Help with Fees is no longer available for probate applications')
context 'when probate fees are no longer supported' do
scenario 'I expect a warning message to be displayed' do
Timecop.freeze(probate_fees_release_date) do
expect(page).to have_css('#probate-warning')
end
end
end
Expand Down
26 changes: 2 additions & 24 deletions spec/models/forms/form_name_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
require 'rails_helper'

RSpec.describe Forms::FormName, type: :model do
subject(:form) { described_class.new(identifier: identifier, unknown: unknown, et: et, probate: probate) }
subject(:form) { described_class.new(identifier: identifier, unknown: unknown, et: et) }

let(:et) { false }
let(:identifier) { nil }
let(:probate) { false }
let(:unknown) { false }
let(:et) { false }

describe 'validations' do
describe 'identifier' do
Expand Down Expand Up @@ -48,26 +46,6 @@
end
end
end

describe 'probate' do
context 'when it is false' do
let(:probate) { false }

it 'has no probate validation errors' do
form.valid?
expect(form.errors[:probate].count).to eq 0
end
end

context 'when it is true' do
let(:probate) { true }

it 'has porbate validation errors' do
form.valid?
expect(form.errors[:probate].count).to eq 1
end
end
end
end

describe '#export' do
Expand Down
4 changes: 0 additions & 4 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
# particularly slow.
config.profile_examples = 10 if ENV['RACK_ENV'].eql?('test')

Capybara::Webkit.configure do |config|
config.block_unknown_urls
end

# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
Expand Down
2 changes: 1 addition & 1 deletion spec/support/webmock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

RSpec.configure do |config|
config.before(:all) do
WebMock.disable_net_connect!(allow: %w[codeclimate.com 127.0.0.1])
WebMock.disable_net_connect!(allow: %w[codeclimate.com])
end
end

0 comments on commit 4799a15

Please sign in to comment.