diff options
author | Iain Hecker <github@iain.nl> | 2008-08-16 20:22:40 +0200 |
---|---|---|
committer | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-08-20 17:39:43 +0200 |
commit | c531248938302477c5e52138d59a6c3d1527d963 (patch) | |
tree | 547c8ece3d9979f781c51086e108347466ca378d /activerecord | |
parent | ae8a35d8f6d5db6ae9a1877918d45c15d21e24fe (diff) | |
download | rails-c531248938302477c5e52138d59a6c3d1527d963.tar.gz rails-c531248938302477c5e52138d59a6c3d1527d963.tar.bz2 rails-c531248938302477c5e52138d59a6c3d1527d963.zip |
Introduced AR::Base.human_name to validations
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/validations_i18n_test.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 92b3e9a597..040681a09c 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -100,7 +100,7 @@ module ActiveRecord options.merge!({ :default => defaults, - :model => I18n.translate(model_name.underscore, :default => model_name.humanize, :scope => [:activerecord, :models], :count => 1), + :model => @base.class.human_name, :attribute => @base.class.human_attribute_name(attribute.to_s), :scope => [:activerecord, :errors, :messages] }) diff --git a/activerecord/test/cases/validations_i18n_test.rb b/activerecord/test/cases/validations_i18n_test.rb index e110595437..96f86fbe0e 100644 --- a/activerecord/test/cases/validations_i18n_test.rb +++ b/activerecord/test/cases/validations_i18n_test.rb @@ -46,7 +46,7 @@ class ActiveRecordValidationsI18nTests < Test::Unit::TestCase global_scope = [:activerecord, :errors, :messages] custom_scope = global_scope + [:custom, 'topic', :title] - I18n.expects(:translate).with('topic', {:count => 1, :default => 'Topic', :scope => [:activerecord, :models]}).returns('Topic') + I18n.expects(:translate).with(:topic, {:count => 1, :default => ['Topic'], :scope => [:activerecord, :models]}).returns('Topic') I18n.expects(:translate).with(:'topic.title', {:count => 1, :default => ['Title'], :scope => [:activerecord, :attributes]}).returns('Title') I18n.expects(:translate).with(:"custom.topic.title.invalid", :scope => global_scope, :default => [:"custom.topic.invalid", 'default from class def error 1', :invalid], :attribute => "Title", :model => "Topic").returns('default from class def error 1') @topic.errors.generate_message :title, :invalid, :default => 'default from class def error 1' @@ -54,7 +54,7 @@ class ActiveRecordValidationsI18nTests < Test::Unit::TestCase def test_errors_generate_message_translates_custom_model_attribute_keys_with_sti custom_scope = [:activerecord, :errors, :custom, 'topic', :title] - I18n.expects(:translate).with('reply', {:count => 1, :default => 'Reply', :scope => [:activerecord, :models]}).returns('Reply') + I18n.expects(:translate).with(:reply, {:count => 1, :default => [:topic, 'Reply'], :scope => [:activerecord, :models]}).returns('Reply') I18n.expects(:translate).with(:'reply.title', {:count => 1, :default => [:'topic.title', 'Title'], :scope => [:activerecord, :attributes]}).returns('Title') I18n.expects(:translate).with(:"custom.reply.title.invalid", :scope => [:activerecord, :errors, :messages], :default => [:"custom.reply.invalid", :"custom.topic.title.invalid", :"custom.topic.invalid", 'default from class def', :invalid], :model => 'Reply', :attribute => 'Title').returns("default from class def") Reply.new.errors.generate_message :title, :invalid, :default => 'default from class def' |