Permalink
Browse files

Add tests to make sure that the I18n taken message can be overrided i…

…n the

activerecord scope.

Related with 5341b84
  • Loading branch information...
1 parent 8059b82 commit 78adc4529a0447a685be59534c1e627a0a1077d0 @rafaelfranca rafaelfranca committed Oct 22, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
View
14 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -59,4 +59,18 @@ def test_generate_message_taken_with_custom_message
assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, :value => 'title')
end
+ test "translation for 'taken' can be overridden in activerecord scope" do
+ I18n.backend.store_translations "en", {activerecord: {errors: {messages: {taken: "Custom taken message" }}}}
+ assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, :value => 'title')
+ end
+
+ test "translation for 'taken' can be overridden in activerecord model scope" do
+ I18n.backend.store_translations "en", {activerecord: {errors: {models: {topic: {taken: "Custom taken message" }}}}}
+ assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, :value => 'title')
+ end
+
+ test "translation for 'taken' can be overridden in activerecord attributes scope" do
+ I18n.backend.store_translations "en", {activerecord: {errors: {models: {topic: {attributes: {title: {taken: "Custom taken message" }}}}}}}
+ assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, :value => 'title')
+ end
end

0 comments on commit 78adc45

Please sign in to comment.