Skip to content

Commit

Permalink
Iban validator test fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
leio10 committed Oct 4, 2017
1 parent 3f32010 commit 1d1cc02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/active_model/validations/iban_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def validate_each(record, attribute, value)
elsif !IbanBic.valid_check?(value)
record.errors.add(attribute, :invalid_check)
elsif !IbanBic.valid_country_check?(value)

record.errors.add(attribute, :invalid_country_check)
end
end
Expand Down
9 changes: 7 additions & 2 deletions spec/validators/iban_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ def self.model_name
end

context "when invalid country digits" do
let(:iban_digits) { "17" }
let(:iban_digits) { "07" }
let(:country_digits) { "00" }
it { is_expected.to be_invalid }
it "iban is valid" do
expect(IbanBic.valid_check?(iban)).to be_truthy
end
it "but country digits not" do
is_expected.to be_invalid
end
end

context "when invalid format" do
Expand Down

0 comments on commit 1d1cc02

Please sign in to comment.