Skip to content
Browse files

Test to_model being called in ActiveModel::Naming helpers

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 33aaa15 commit 21cb1d40b9c57ab814c69d01a242b50e27e8283b @ernie ernie committed with josevalim Oct 4, 2010
Showing with 11 additions and 0 deletions.
  1. +4 −0 activemodel/test/cases/naming_test.rb
  2. +7 −0 activemodel/test/models/track_back.rb
View
4 activemodel/test/cases/naming_test.rb
@@ -125,6 +125,10 @@ def setup
@param_key = 'contact'
end
+ def test_to_model_called_on_record
+ assert_equal 'post_named_track_backs', plural(Post::TrackBack.new)
+ end
+
def test_singular
assert_equal @singular, singular(@record)
end
View
7 activemodel/test/models/track_back.rb
@@ -1,4 +1,11 @@
class Post
class TrackBack
+ def to_model
+ NamedTrackBack.new(self)
+ end
+ end
+
+ class NamedTrackBack
+ extend ActiveModel::Naming
end
end

0 comments on commit 21cb1d4

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