diff options
author | Tammer Saleh <tsaleh@thoughtbot.com> | 2008-06-20 15:21:04 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-22 18:58:47 -0700 |
commit | bb6e8eea5a8190aaab67da0a7efedb3bb3d9fccb (patch) | |
tree | 099fea2c0fd42c87044889deae59e652e9a09f00 /actionpack/test | |
parent | a210f503619dd27dc9575bcae1df596fd2387563 (diff) | |
download | rails-bb6e8eea5a8190aaab67da0a7efedb3bb3d9fccb.tar.gz rails-bb6e8eea5a8190aaab67da0a7efedb3bb3d9fccb.tar.bz2 rails-bb6e8eea5a8190aaab67da0a7efedb3bb3d9fccb.zip |
Fixed polymorphic_url to be able to handle singleton resources.
Example usage:
polymorphic_url([:admin, @user, :blog, @post]) # => admin_user_blog_post_url(@user, @post)
[#461 state:resolved]
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/polymorphic_routes_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb index 4ec0d3cd4e..3f52526f08 100644 --- a/actionpack/test/controller/polymorphic_routes_test.rb +++ b/actionpack/test/controller/polymorphic_routes_test.rb @@ -118,6 +118,39 @@ uses_mocha 'polymorphic URL helpers' do polymorphic_url([:site, :admin, @article, @response, @tag]) end + def test_nesting_with_array_ending_in_singleton_resource + expects(:article_response_url).with(@article) + polymorphic_url([@article, :response]) + end + + def test_nesting_with_array_containing_singleton_resource + @tag = Tag.new + @tag.save + expects(:article_response_tag_url).with(@article, @tag) + polymorphic_url([@article, :response, @tag]) + end + + def test_nesting_with_array_containing_namespace_and_singleton_resource + @tag = Tag.new + @tag.save + expects(:admin_article_response_tag_url).with(@article, @tag) + polymorphic_url([:admin, @article, :response, @tag]) + end + + def test_nesting_with_array_containing_singleton_resource_and_format + @tag = Tag.new + @tag.save + expects(:formatted_article_response_tag_url).with(@article, @tag, :pdf) + formatted_polymorphic_url([@article, :response, @tag, :pdf]) + end + + def test_nesting_with_array_containing_singleton_resource_and_format_option + @tag = Tag.new + @tag.save + expects(:article_response_tag_url).with(@article, @tag, :pdf) + polymorphic_url([@article, :response, @tag], :format => :pdf) + end + # TODO: Needs to be updated to correctly know about whether the object is in a hash or not def xtest_with_hash expects(:article_url).with(@article) |