You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when you define a 'validates_presence_of :something' on a model, this is only checked for translations in the current locale but not for any other translations you set using 'set_translations':
test "validates_presence_of using set_translations" do
Validatee.class_eval { validates_presence_of :string }
assert !Validatee.new.valid?
assert Validatee.new(:string => 'foo').valid?
### The following fails
assert_nothing_raised do
Validatee.new(:string => 'bar').set_translations(:fr => { :string => '' })
end
end
One solution is to set the validations on the translation class itself:
test "" do
Validatee.translation_class.class_eval do
validates_presence_of :string
end
I18n.locale = :en
validatee = Validatee.new(:string => "a string")
assert validatee.valid?
validatee.set_translations(:nl => {:string => ''}) rescue nil # we need to recsue as set_translations uses update_attributes!
assert !validatee.valid? ### this works
end
The text was updated successfully, but these errors were encountered:
when you define a 'validates_presence_of :something' on a model, this is only checked for translations in the current locale but not for any other translations you set using 'set_translations':
test "validates_presence_of using set_translations" do
Validatee.class_eval { validates_presence_of :string }
assert !Validatee.new.valid?
assert Validatee.new(:string => 'foo').valid?
### The following fails
assert_nothing_raised do
Validatee.new(:string => 'bar').set_translations(:fr => { :string => '' })
end
end
One solution is to set the validations on the translation class itself:
test "" do
Validatee.translation_class.class_eval do
validates_presence_of :string
end
end
The text was updated successfully, but these errors were encountered: