Skip to content

Commit

Permalink
errors.rb needs to be declared as UTF-8 [#3941 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information
tenderlove authored and wycats committed Apr 2, 2010
1 parent 3adaef8 commit 30f3a3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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'
Expand Down
10 changes: 10 additions & 0 deletions 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'
Expand Down Expand Up @@ -41,6 +43,14 @@ def test_errors_add_on_blank_generates_message_with_custom_default_message
@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")
Expand Down

0 comments on commit 30f3a3d

Please sign in to comment.