validates_cpf 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/validates_cpf.rb +1 -1
- data/lib/validates_cpf/version.rb +1 -1
- data/spec/validates_cpf_spec.rb +2 -0
- metadata +1 -1
data/lib/validates_cpf.rb
CHANGED
@@ -7,6 +7,6 @@ require "validates_cpf/remarkable/require_a_valid_cpf_matcher" if defined?(::Rem
|
|
7
7
|
class CpfValidator < ActiveModel::EachValidator
|
8
8
|
def validate_each(record, attribute, value)
|
9
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 CPF.new(value).valid?
|
10
|
+
record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless CPF.new(value).valid?
|
11
11
|
end
|
12
12
|
end
|
data/spec/validates_cpf_spec.rb
CHANGED
@@ -4,6 +4,8 @@ describe CpfValidator do
|
|
4
4
|
context "when cpf is invalid" do
|
5
5
|
before :each do
|
6
6
|
@user = User.new(:cpf => "12345")
|
7
|
+
I18n.stub(:t).with(:"activerecord.errors.models.user.attributes.cpf.invalid",
|
8
|
+
:default => :"activerecord.errors.messages.invalid").and_return("is invalid")
|
7
9
|
end
|
8
10
|
|
9
11
|
it "should set object as invalid" do
|