From d4e0e33d2ad9ee2072b3fcfb38abfb02842dd84f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 1 Apr 2010 21:42:03 -0700 Subject: [PATCH] errors.rb needs to be declared as UTF-8 [#3941 state:resolved] --- activemodel/lib/active_model/errors.rb | 2 ++ .../test/cases/validations/i18n_validation_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 8d28040..64b28f6 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 38844bb..7dd82e7 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") -- 1.6.6