Skip to content

Commit

Permalink
Doesn't accept 'isento' as a valid IE (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lourenci authored and marcosdemelo committed Nov 30, 2017
1 parent 2377204 commit 9eae686
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
8 changes: 1 addition & 7 deletions lib/br_documents/ie_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion lib/br_documents/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BrDocuments
VERSION = "0.0.13"
VERSION = "0.0.14"
end
8 changes: 0 additions & 8 deletions spec/ie_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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", "") }

Expand Down

0 comments on commit 9eae686

Please sign in to comment.