Skip to content
Browse files

failing test for i18n key collision with namespaced models

  • Loading branch information...
1 parent f7e1703 commit d043d20eb05f15b52f7bf1f84b3e7bc40d71098c @spastorino spastorino committed
Showing with 11 additions and 0 deletions.
  1. +7 −0 activemodel/test/cases/translation_test.rb
  2. +4 −0 activemodel/test/models/person.rb
View
7 activemodel/test/cases/translation_test.rb
@@ -32,6 +32,13 @@ def test_translated_model_attributes_with_ancestors_fallback
assert_equal 'person name attribute', Child.human_attribute_name('name')
end
+ def test_translated_model_attributes_with_attribute_matching_namespaced_model_name
+ I18n.backend.store_translations 'en', :activemodel => {:attributes => {:person => {:gender => 'person gender'}, :"person/gender" => {:attribute => 'person gender attribute'}}}
+
+ assert_equal 'person gender', Person.human_attribute_name('gender')
+ assert_equal 'person gender attribute', Person::Gender.human_attribute_name('attribute')
+ end
+
def test_translated_model_names
I18n.backend.store_translations 'en', :activemodel => {:models => {:person => 'person model'} }
assert_equal 'person model', Person.model_name.human
View
4 activemodel/test/models/person.rb
@@ -9,6 +9,10 @@ def condition_is_true
end
end
+class Person::Gender
+ extend ActiveModel::Translation
+end
+
class Child < Person
end

0 comments on commit d043d20

Please sign in to comment.
Something went wrong with that request. Please try again.