validates_cnpj 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ValidatesCnpj
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -6,6 +6,7 @@ require "validates_cnpj/remarkable/require_a_valid_cnpj_matcher" if defined?(::R
6
6
 
7
7
  class CnpjValidator < ActiveModel::EachValidator
8
8
  def validate_each(record, attribute, value)
9
- record.errors[attribute] << I18n.t("activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid") unless CNPJ.new(value).valid?
9
+ key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
10
+ record.errors[attribute] << I18n.t(key, :default => :"errors.messages.invalid") unless CNPJ.new(value).valid?
10
11
  end
11
12
  end
@@ -4,7 +4,6 @@ describe CnpjValidator do
4
4
  context "when cnpj is invalid" do
5
5
  before :each do
6
6
  @company = Company.new(:cnpj => "12345")
7
- I18n.stub(:t).with("activerecord.errors.models.company.attributes.cnpj.invalid").and_return("is invalid")
8
7
  end
9
8
 
10
9
  it "should set object as invalid" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_cnpj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: