From 9eae6863004806d20297bdce0e55f5660b94dff2 Mon Sep 17 00:00:00 2001 From: Leandro Lourenci Date: Thu, 30 Nov 2017 11:20:04 -0200 Subject: [PATCH] Doesn't accept 'isento' as a valid IE (#5) --- lib/br_documents/ie_validator.rb | 8 +------- lib/br_documents/version.rb | 2 +- spec/ie_validator_spec.rb | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/br_documents/ie_validator.rb b/lib/br_documents/ie_validator.rb index e7b7f7c..a45660c 100644 --- a/lib/br_documents/ie_validator.rb +++ b/lib/br_documents/ie_validator.rb @@ -31,9 +31,7 @@ def can_read_uf_at_record?(options, record, attribute) def ie_valid?(record, attribute, value) begin - if (not number_valid?(record, value)) && (not exempted?(value)) - record.errors.add(attribute, :invalid) - end + record.errors.add(attribute, :invalid) unless number_valid?(record, value) rescue ArgumentError => ex record.errors.add(attribute, ex.message) end @@ -46,10 +44,6 @@ def number_valid?(record, value) ie_number.valid? end - def exempted?(value) - "isento".casecmp(value) == 0 - end - def read_uf(record) attribute = record options[:uf].split("#").each do | field | diff --git a/lib/br_documents/version.rb b/lib/br_documents/version.rb index 1691ae6..998d2b1 100644 --- a/lib/br_documents/version.rb +++ b/lib/br_documents/version.rb @@ -1,3 +1,3 @@ module BrDocuments - VERSION = "0.0.13" + VERSION = "0.0.14" end diff --git a/spec/ie_validator_spec.rb b/spec/ie_validator_spec.rb index d41baa5..b50adfa 100644 --- a/spec/ie_validator_spec.rb +++ b/spec/ie_validator_spec.rb @@ -22,14 +22,6 @@ end end - context "when IE is 'ISENTO'" do - before { subject.validate_each(record, "ie", "ISENTO") } - - it "doesn't add errors in model" do - expect(record.errors.messages).to be_empty - end - end - context "when IE is blank" do before { subject.validate_each(record, "ie", "") }