aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/errors.rb2
-rw-r--r--activemodel/test/cases/validations/i18n_validation_test.rb10
2 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 8d28040c32..64b28f6def 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/object/blank'
diff --git a/activemodel/test/cases/validations/i18n_validation_test.rb b/activemodel/test/cases/validations/i18n_validation_test.rb
index 38844bb1fa..7dd82e711d 100644
--- a/activemodel/test/cases/validations/i18n_validation_test.rb
+++ b/activemodel/test/cases/validations/i18n_validation_test.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require "cases/helper"
require 'cases/tests_database'
require 'models/person'
@@ -41,6 +43,14 @@ class I18nValidationTest < ActiveModel::TestCase
@person.errors.add_on_blank :title, 'custom'
end
+ def test_full_message_encoding
+ I18n.backend.store_translations('en', :errors => {
+ :messages => { :too_short => '猫舌' }})
+ Person.validates_length_of :title, :within => 3..5
+ @person.valid?
+ assert_equal ['Title 猫舌'], @person.errors.full_messages
+ end
+
def test_errors_full_messages_translates_human_attribute_name_for_model_attributes
@person.errors.add(:name, 'not found')
Person.expects(:human_attribute_name).with(:name, :default => 'Name').returns("Person's name")