diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-05-12 00:18:42 -0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-05-12 09:31:30 -0700 |
commit | f7862b2c34b5b298bf7b937c55f0637ebfe43a25 (patch) | |
tree | c05c9b3cafaa86dfb69c9d2405d5e8f98fc4a3dd /activemodel/test | |
parent | 42fa2714c5005bb50679bf9a081d8bf0774f7eec (diff) | |
download | rails-f7862b2c34b5b298bf7b937c55f0637ebfe43a25.tar.gz rails-f7862b2c34b5b298bf7b937c55f0637ebfe43a25.tar.bz2 rails-f7862b2c34b5b298bf7b937c55f0637ebfe43a25.zip |
Refactor of active_model/naming.rb and allow collection and element to be writable
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/naming_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index dc39b84ed8..3918002360 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -18,6 +18,26 @@ class NamingTest < ActiveModel::TestCase assert_equal 'track_back', @model_name.element end + def test_set_element + @model_name.element = 'foo' + + assert_equal 'foo', @model_name.element + assert_equal 'Foo', @model_name.human + assert_equal 'post/foos', @model_name.collection + assert_equal 'post/foos/foo', @model_name.partial_path + end + + def test_human + assert_equal 'Track back', @model_name.human + end + + def test_set_collection + @model_name.collection = 'foo' + + assert_equal 'foo', @model_name.collection + assert_equal 'foo/track_back', @model_name.partial_path + end + def test_collection assert_equal 'post/track_backs', @model_name.collection end @@ -25,4 +45,14 @@ class NamingTest < ActiveModel::TestCase def test_partial_path assert_equal 'post/track_backs/track_back', @model_name.partial_path end + + def test_should_preserve_custom_collection + @model_name.collection = 'bar' + @model_name.element = 'foo' + + assert_equal 'foo', @model_name.element + assert_equal 'Foo', @model_name.human + assert_equal 'bar', @model_name.collection + assert_equal 'bar/foo', @model_name.partial_path + end end |