Skip to content

Commit

Permalink
Removing all mentions of building_society and account_type from code.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaparka committed May 22, 2018
1 parent ad9f944 commit 9cb4e1d
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 230 deletions.
36 changes: 3 additions & 33 deletions app/forms/refunds/bank_details_form.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,17 @@
module Refunds
class BankDetailsForm < Form
ACCOUNT_TYPES = ['bank', 'building_society'].freeze
attribute :payment_account_type, String
attribute :payment_bank_account_name, String
attribute :payment_bank_name, String
attribute :payment_bank_account_number, String
attribute :payment_bank_sort_code, String
attribute :payment_building_society_account_name, String
attribute :payment_building_society_name, String
attribute :payment_building_society_account_number, String
attribute :payment_building_society_sort_code, String

validates :payment_account_type, presence: true, inclusion: { in: ACCOUNT_TYPES }
validates :payment_bank_account_name, :payment_bank_name, presence: true, if: :is_bank_type?
validates :payment_bank_account_name, :payment_bank_name, presence: true
validates :payment_bank_account_number,
presence: true,
format: { with: %r(\A\d{8}\z), allow_blank: true },
if: :is_bank_type?
format: { with: %r(\A\d{8}\z), allow_blank: true }
validates :payment_bank_sort_code,
presence: true,
format: { with: %r(\A\d{6}\z), allow_blank: true },
if: :is_bank_type?
validates :payment_building_society_account_name,
:payment_building_society_name,
presence: true,
if: :is_building_society_type?
validates :payment_building_society_account_number,
presence: true,
format: { with: %r(\A\d{8}\z), allow_blank: true },
if: :is_building_society_type?
validates :payment_building_society_sort_code,
presence: true,
format: { with: %r(\A\d{6}\z), allow_blank: true },
if: :is_building_society_type?

private

def is_bank_type?
payment_account_type == 'bank'
end
format: { with: %r(\A\d{6}\z), allow_blank: true }

def is_building_society_type?
payment_account_type == 'building_society'
end
end
end
4 changes: 1 addition & 3 deletions app/views/refunds/_bank_details.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
fieldset
span = t('.account_help')

= f.input :payment_account_type, as: :hidden, input_html: { value: 'bank' }

fieldset.reveal-subscribe data-target='payment_account_type'
fieldset.reveal-subscribe
legend = t('.your_bank_details')
= f.input :payment_bank_name, required: true, input_html: {class: 'medium-input'}
= f.input :payment_bank_account_name, required: true, input_html: {class: 'medium-input'}
Expand Down
50 changes: 16 additions & 34 deletions app/views/refunds/_review.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -162,40 +162,22 @@ div class=("review-list-entry applicant")
th = t('.total_fees')
td = number_to_currency(f.object.total_fees, delimiter: '', precision: 0)
div data-behavior= "refund-review-section"
- if f.object.payment_account_type == 'bank'
h2.list-header
span = t '.sections.bank_details'
= link_to t('.edit'), refund_bank_details_path(return_to_review: true)
table.review-table
tr
th = t('.payment_bank_account_name')
td = f.object.payment_bank_account_name
tr
th = t('.payment_bank_name')
td = f.object.payment_bank_name
tr
th = t('.payment_bank_account_number')
td = f.object.payment_bank_account_number
tr
th = t('.payment_bank_sort_code')
td = f.object.payment_bank_sort_code
- if f.object.payment_account_type == 'building_society'
h2.list-header
span = t '.sections.building_society_details'
= link_to t('.edit'), refund_bank_details_path(return_to_review: true)
table.review-table
tr
th = t('.payment_building_society_account_name')
td = f.object.payment_building_society_account_name
tr
th = t('.payment_building_society_name')
td = f.object.payment_building_society_name
tr
th = t('.payment_building_society_account_number')
td = f.object.payment_building_society_account_number
tr
th = t('.payment_building_society_sort_code')
td = f.object.payment_building_society_sort_code
h2.list-header
span = t '.sections.bank_details'
= link_to t('.edit'), refund_bank_details_path(return_to_review: true)
table.review-table
tr
th = t('.payment_bank_account_name')
td = f.object.payment_bank_account_name
tr
th = t('.payment_bank_name')
td = f.object.payment_bank_name
tr
th = t('.payment_bank_account_number')
td = f.object.payment_bank_account_number
tr
th = t('.payment_bank_sort_code')
td = f.object.payment_bank_sort_code
fieldset
legend= t '.declaration'
p = t('.declaration_i_confirm')
Expand Down
29 changes: 0 additions & 29 deletions config/locales/refunds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ en:
fees_help_type_appeal: "An Employment Appeal Tribunal fee had a lodgement fee of £400 and a hearing fee of £1200."
bank_details:
your_bank_details: "Your Bank/Building Society Details"
your_building_society_details: "Your Building Society Details"
header: "Repayment Details"
account_help: "We can only make payment to a UK bank account in the name of the person or organisation making this refund application."
review:
Expand All @@ -76,7 +75,6 @@ en:
original_case_details: "Original Case Details"
original_case_fees: "Original Case Fees"
bank_details: "Your Bank/Building Society Details"
building_society_details: "Your Building Society Details"
full_name: "Full Name"
date_of_birth: "Date Of Birth"
applicant_email_address: "Email Address"
Expand Down Expand Up @@ -104,10 +102,6 @@ en:
payment_bank_name: "Bank/Building Society Name"
payment_bank_account_number: "Account number"
payment_bank_sort_code: "Sort code"
payment_building_society_account_name: "Account Name"
payment_building_society_name: "Building society name"
payment_building_society_account_number: "Account number"
payment_building_society_sort_code: "Sort code"
declaration: "Declaration"
declaration_detail_html: |
I am making an application on behalf of myself.
Expand Down Expand Up @@ -272,8 +266,6 @@ en:
fees_must_be_positive: You must enter a fee in the relevant field
refunds/bank_details:
attributes:
payment_account_type:
blank: Please select one of the options
payment_bank_account_name:
blank: Enter Account Name
payment_bank_name:
Expand All @@ -284,23 +276,10 @@ en:
payment_bank_sort_code:
blank: Enter Sort Code
invalid: Must be 6 numbers
payment_building_society_account_name:
blank: Enter the name on the building society account
payment_building_society_name:
blank: Enter the name of the building society
payment_building_society_account_number:
blank: Enter the account number that the refund is to be paid into
invalid: Must be 8 numbers
payment_building_society_sort_code:
blank: Enter the sort code of the account that the refund is to be paid into
invalid: Must be 6 numbers

simple_form:
include_blanks:
refunds_applicant:
applicant_title: Please select
refunds_bank_details:
payment_account_type: Please select
refunds_original_case_details:
et_country_of_claim: Please select
et_tribunal_office: Please select
Expand Down Expand Up @@ -339,8 +318,6 @@ en:
refunds_bank_details:
payment_bank_account_number: Please enter your 8 digit bank account number. This should be a current account held in your name, not a savings account
payment_bank_sort_code: Please enter the sort code as a six digit number, eg. 112233, please do not include any spaces or dashes
payment_building_society_account_number: Please enter your 8 digit building society account number. This should be a current account held in your name, not a savings account
payment_building_society_sort_code: Please enter the sort code as a six digit number, eg. 112233, please do not include any spaces or dashes
labels:
refunds_applicant:
applicant_address_building: Building number or name
Expand Down Expand Up @@ -376,15 +353,10 @@ en:
et_tribunal_office: Employment tribunal office
et_country_of_claim: Where was your claim issued?
refunds_bank_details:
payment_account_type: Account type
payment_bank_account_name: Account Name
payment_bank_name: Bank/Building Society name
payment_bank_account_number: Account number
payment_bank_sort_code: Sort code
payment_building_society_account_name: Building Society account holder name
payment_building_society_name: Building Society name
payment_building_society_account_number: Building Society account number
payment_building_society_sort_code: Building Society sort code
refunds_fees:
et_issue_fee_payment_date_unknown: Don't know
et_hearing_fee_payment_date_unknown: Don't know
Expand Down Expand Up @@ -465,5 +437,4 @@ en:
refunds_bank_details:
payment_account_type:
bank: Bank/Building Society
building_society: Building Society

4 changes: 0 additions & 4 deletions features/step_definitions/refunds/payment_details_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
end
end

And(/^I select "([^"]*)" account type in the refund bank details page$/) do |account_type|
refund_payment_details_page.account_type.select(account_type)
end

Then(/^only the bank details account type field should be marked with an error$/) do
expect(refund_payment_details_page.account_type.error.text).to eql "Please select one of the options"
expect(refund_payment_details_page.bank_details.account_name).to have_no_error
Expand Down
15 changes: 0 additions & 15 deletions features/step_definitions/refunds/review_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,10 @@
end
end

And(/^I verify the building society details in the bank details of the refund review page$/) do
refund_review_page.building_society_details do |section|
expect(section.account_name.text).to eql test_user.building_society_account.account_name
expect(section.building_society_name.text).to eql test_user.building_society_account.building_society_name
expect(section.account_number.text).to eql test_user.building_society_account.account_number
expect(section.sort_code.text).to eql test_user.building_society_account.sort_code
end
end

And(/^I verify the bank details are not present in the bank details of the review page$/) do
expect(refund_review_page).to have_no_bank_details
end

And(/^I verify the building society details are not present in the bank details of the refund review page$/) do
expect(refund_review_page).to have_no_building_society_details
end

And(/^I verify the review page and accept the declaration$/) do
step 'I verify the claimant section of the refund review page'
step 'I verify the claimants contact details of the refund review page'
Expand All @@ -184,8 +171,6 @@
step 'I verify the fees in the case details of the refund review page'
step 'I verify the bank details in the bank details of the refund review page' if test_user.bank_account.present?
step 'I verify the bank details are not present in the bank details of the review page' if test_user.bank_account.blank?
step 'I verify the building society details in the bank details of the refund review page' if test_user.building_society_account.present?
step 'I verify the building society details are not present in the bank details of the refund review page' if test_user.building_society_account.blank?
step 'I accept the refund final declaration'
end

Expand Down
7 changes: 0 additions & 7 deletions features/step_definitions/refunds/setup_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@
sort_code: '012345'
end

And(/^I have a building society account$/) do
test_user.building_society_account = OpenStruct.new account_name: 'Mr Luke Skywalker',
building_society_name: 'Starship Enterprises Building Society',
account_number: '12345678',
sort_code: '012345'
end

And(/^my name has not changed since the original claim that I want a refund for$/) do
test_user.has_name_changed = 'No'
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Refunds
class PaymentDetailsPage < BasePage
set_url "/apply/refund/bank-details"
section :account_type, AppTest::FormSelect, :simple_form_field, 'Account type'
section :bank_details, :xpath, (XPath.generate { |x| x.descendant(:fieldset)[x.descendant(:legend)[x.string.n.is("Your Bank/Building Society Details")]] }) do
section :account_name, AppTest::FormInput, :simple_form_field, 'Account Name'
section :bank_name, AppTest::FormInput, :simple_form_field, 'Bank/Building Society name'
Expand Down
7 changes: 0 additions & 7 deletions features/support/page_objects/refund/review_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ class ReviewPage < BasePage
element :sort_code, :refund_review_section_field_labelled, 'Sort code'
end

section :building_society_details, :refund_review_section_labelled, 'Your Building Society Details' do
element :account_name, :refund_review_section_field_labelled, 'Account Name'
element :building_society_name, :refund_review_section_field_labelled, 'Building society name'
element :account_number, :refund_review_section_field_labelled, 'Account number'
element :sort_code, :refund_review_section_field_labelled, 'Sort code'
end

section :declaration, :xpath, (XPath.generate { |x| x.descendant(:fieldset)[x.descendant(:legend)[x.string.n.is("Declaration")]] }) do
element :accept, 'Tick to confirm'

Expand Down
1 change: 0 additions & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@
applicant_first_name 'First'
applicant_last_name 'Last'
additional_information 'Some extra information'
payment_account_type 'bank'
submitted_at DateTime.parse('1 December 2016 00:00:00').utc
end
end
Loading

0 comments on commit 9cb4e1d

Please sign in to comment.