mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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]
This commit is contained in:
committed by
Jeremy Kemper
parent
a210f50361
commit
bb6e8eea5a
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user