ibandit 0.8.8 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 101e32709372c4aa77b414ffd6a51e72b76d01c0
4
- data.tar.gz: 18864657f16536a50ef7037a1e0c3d583c94693f
3
+ metadata.gz: a8c359511af493cf0c67d92be073707e7e89aafa
4
+ data.tar.gz: 086f4eb19008f7deafe3112d7902e684adc41a0c
5
5
  SHA512:
6
- metadata.gz: a7d31438134017276eea2e49cd41861cc9f52da897e3954a0315bb8f405867e864935c4b9538eff7dd44bff0fc0db41f4d4750aab916ea0ce49bf9acad63fa6b
7
- data.tar.gz: 3069f177708f23613f0d3d7e35837ae77b6366aed8aaae399e3a9f7fd24b281634d9515c0a55068deb1ebbe0659b5a9fdfe786725838a166be7c7a22056d0cad
6
+ metadata.gz: 42bbedef82e946bf3e563949d9f30a387704b848a0043de9b8d6cb37347ce136895167ac8dc1f40da129ec3e47995b17964c2c35d30855847307d8b5abeb3e84
7
+ data.tar.gz: 24f02a0e80d6bb64361741a465b3da217839d9fa695634d481ad7b98649a6573b9048b1251aba74e5d679a97810bc9543633a367242047e8341e52e5bd36d3ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.9.0 - January 25, 2016
2
+
3
+ - BREAKING CHANGE: Update modulus checker hooks to expect a `valid_branch_code?`
4
+ method. See https://github.com/gocardless/ibandit/pull/65 for more details.
5
+
1
6
  ## 0.8.8 - January 22, 2016
2
7
 
3
8
  - Strip whitespace from Spanish account numbers
data/lib/ibandit/iban.rb CHANGED
@@ -243,7 +243,9 @@ module Ibandit
243
243
  return unless valid_format?
244
244
  return true unless Ibandit.modulus_checker
245
245
 
246
- valid_modulus_check_bank_code? && valid_modulus_check_account_number?
246
+ valid_modulus_check_bank_code? &&
247
+ valid_modulus_check_branch_code? &&
248
+ valid_modulus_check_account_number?
247
249
  end
248
250
 
249
251
  def passes_country_specific_checks?
@@ -385,7 +387,14 @@ module Ibandit
385
387
  def valid_modulus_check_bank_code?
386
388
  return true if Ibandit.modulus_checker.valid_bank_code?(iban.to_s)
387
389
 
388
- @errors[modulus_check_bank_code_field] = Ibandit.translate(:is_invalid)
390
+ @errors[:bank_code] = Ibandit.translate(:is_invalid)
391
+ false
392
+ end
393
+
394
+ def valid_modulus_check_branch_code?
395
+ return true if Ibandit.modulus_checker.valid_branch_code?(iban.to_s)
396
+
397
+ @errors[:branch_code] = Ibandit.translate(:is_invalid)
389
398
  false
390
399
  end
391
400
 
@@ -396,15 +405,6 @@ module Ibandit
396
405
  false
397
406
  end
398
407
 
399
- def modulus_check_bank_code_field
400
- if LocalDetailsCleaner.required_fields(country_code).
401
- include?(:branch_code)
402
- :branch_code
403
- else
404
- :bank_code
405
- end
406
- end
407
-
408
408
  def swift_details
409
409
  {
410
410
  country_code: @country_code,
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = '0.8.8'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -1137,6 +1137,7 @@ describe Ibandit::IBAN do
1137
1137
  before do
1138
1138
  Ibandit.modulus_checker = double(
1139
1139
  valid_bank_code?: valid_bank_code,
1140
+ valid_branch_code?: valid_branch_code,
1140
1141
  valid_account_number?: valid_account_number)
1141
1142
  end
1142
1143
  after { Ibandit.modulus_checker = nil }
@@ -1145,6 +1146,7 @@ describe Ibandit::IBAN do
1145
1146
  context 'with an invalid bank code' do
1146
1147
  let(:iban_code) { 'AT611904300234573201' }
1147
1148
  let(:valid_bank_code) { false }
1149
+ let(:valid_branch_code) { true }
1148
1150
  let(:valid_account_number) { true }
1149
1151
 
1150
1152
  it { is_expected.to be(false) }
@@ -1177,60 +1179,64 @@ describe Ibandit::IBAN do
1177
1179
  context 'locale nl', locale: :nl do
1178
1180
  specify { expect(iban.errors).to include(bank_code: 'is ongeldig') }
1179
1181
  end
1182
+ end
1180
1183
 
1181
- context 'when the bank code is not required' do
1182
- let(:iban_code) { 'GB60BARC20000055779911' }
1183
- before { Ibandit.bic_finder = double(call: 'BARCGB22XXX') }
1184
- after { Ibandit.bic_finder = nil }
1185
- before { iban.valid_local_modulus_check? }
1184
+ context 'with an invalid branch code' do
1185
+ let(:iban_code) { 'GB60BARC20000055779911' }
1186
+ before { Ibandit.bic_finder = double(call: 'BARCGB22XXX') }
1187
+ after { Ibandit.bic_finder = nil }
1188
+ before { iban.valid_local_modulus_check? }
1189
+ let(:valid_bank_code) { true }
1190
+ let(:valid_branch_code) { false }
1191
+ let(:valid_account_number) { true }
1186
1192
 
1187
- it { is_expected.to be(false) }
1188
- context 'locale en', locale: :en do
1189
- specify do
1190
- expect(iban.errors).to include(branch_code: 'is invalid')
1191
- end
1193
+ it { is_expected.to be(false) }
1194
+ context 'locale en', locale: :en do
1195
+ specify do
1196
+ expect(iban.errors).to include(branch_code: 'is invalid')
1192
1197
  end
1198
+ end
1193
1199
 
1194
- context 'locale fr', locale: :fr do
1195
- specify do
1196
- expect(iban.errors).to include(branch_code: 'est invalide')
1197
- end
1200
+ context 'locale fr', locale: :fr do
1201
+ specify do
1202
+ expect(iban.errors).to include(branch_code: 'est invalide')
1198
1203
  end
1204
+ end
1199
1205
 
1200
- context 'locale de', locale: :de do
1201
- specify do
1202
- expect(iban.errors).to include(branch_code: 'ist nicht gültig')
1203
- end
1206
+ context 'locale de', locale: :de do
1207
+ specify do
1208
+ expect(iban.errors).to include(branch_code: 'ist nicht gültig')
1204
1209
  end
1210
+ end
1205
1211
 
1206
- context 'locale pt', locale: :pt do
1207
- specify do
1208
- expect(iban.errors).to include(branch_code: 'é inválido')
1209
- end
1212
+ context 'locale pt', locale: :pt do
1213
+ specify do
1214
+ expect(iban.errors).to include(branch_code: 'é inválido')
1210
1215
  end
1216
+ end
1211
1217
 
1212
- context 'locale es', locale: :es do
1213
- specify do
1214
- expect(iban.errors).to include(branch_code: 'es inválido')
1215
- end
1218
+ context 'locale es', locale: :es do
1219
+ specify do
1220
+ expect(iban.errors).to include(branch_code: 'es inválido')
1216
1221
  end
1222
+ end
1217
1223
 
1218
- context 'locale it', locale: :it do
1219
- specify do
1220
- expect(iban.errors).to include(branch_code: 'non è valido')
1221
- end
1224
+ context 'locale it', locale: :it do
1225
+ specify do
1226
+ expect(iban.errors).to include(branch_code: 'non è valido')
1222
1227
  end
1228
+ end
1223
1229
 
1224
- context 'locale nl', locale: :nl do
1225
- specify do
1226
- expect(iban.errors).to include(branch_code: 'is ongeldig')
1227
- end
1230
+ context 'locale nl', locale: :nl do
1231
+ specify do
1232
+ expect(iban.errors).to include(branch_code: 'is ongeldig')
1228
1233
  end
1229
1234
  end
1230
1235
  end
1231
1236
 
1232
1237
  context 'with an invalid account number' do
1233
1238
  let(:valid_bank_code) { true }
1239
+ let(:valid_branch_code) { true }
1234
1240
  let(:valid_account_number) { false }
1235
1241
 
1236
1242
  it { is_expected.to be(false) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec