Skip to content

Commit

Permalink
Merge pull request #109 from gocardless/fix-short-account-number
Browse files Browse the repository at this point in the history
Fix short account number
  • Loading branch information
ivgiuliani authored Sep 18, 2018
2 parents 101d6b0 + 5db9068 commit d45397a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.17 - September 17, 2018

- Do not crash when given too short account numbers for New Zealand

## 0.11.16 - September 3, 2018

- Loosen `i18n` dependency (thanks @glaszig!)
Expand Down
2 changes: 1 addition & 1 deletion lib/ibandit/local_details_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def self.clean_nz_details(local_details)
account_number = cleaned_account_number[6..-1]
end

if account_number.length == 9
if account_number && account_number.length == 9
# > Some banks (such as BNZ) include three digits of the suffix in their
# > presentation of the account number to the end customer. Other banks
# > only show the last two digits of the suffix to the end customer.
Expand Down
2 changes: 1 addition & 1 deletion lib/ibandit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ibandit
VERSION = "0.11.16".freeze
VERSION = "0.11.17".freeze
end
5 changes: 5 additions & 0 deletions spec/ibandit/local_details_cleaner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@
its([:branch_code]) { is_expected.to eq("2222") }
its([:account_number]) { is_expected.to eq("3333333044") }
end

context "when the account number is shorter than 6 chars" do
let(:account_number) { "12345" }
its([:account_number]) { is_expected.to be_nil }
end
end

context "without an account number" do
Expand Down

0 comments on commit d45397a

Please sign in to comment.