From 9014bf3f262a6b55aa4a05e2626aeebf688aa05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Thu, 19 Jul 2007 13:42:11 +0000 Subject: * url_for now accepts a series of symbols representing the namespace of the record [Josh Knowles]. Closes #8640 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7197 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/controller/polymorphic_routes_test.rb | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb index 1dc0502f63..3e72063e9e 100644 --- a/actionpack/test/controller/polymorphic_routes_test.rb +++ b/actionpack/test/controller/polymorphic_routes_test.rb @@ -39,6 +39,23 @@ class Test::Unit::TestCase def article_comment_url(article, comment) "http://www.example.com/articles/#{article.id}/comments/#{comment.id}" end + + def admin_articles_url + "http://www.example.com/admin/articles" + end + alias_method :new_admin_article_url, :admin_articles_url + + def admin_article_url(article) + "http://www.example.com/admin/articles/#{article.id}" + end + + def admin_article_comments_url(article) + "http://www.example.com/admin/articles/#{article.id}/comments" + end + + def admin_article_comment_url(article, comment) + "http://www.example.com/admin/test/articles/#{article.id}/comments/#{comment.id}" + end end @@ -68,4 +85,14 @@ class PolymorphicRoutesTest < Test::Unit::TestCase @comment.save assert_equal(article_comment_url(@article, @comment), polymorphic_url([@article, @comment])) end + + def test_with_array_and_namespace + assert_equal(admin_articles_url, polymorphic_url([:admin, @article], :action => 'new')) + assert_equal(admin_articles_url, polymorphic_url([:admin, @article])) + @article.save + assert_equal(admin_article_url(@article), polymorphic_url([:admin, @article])) + assert_equal(admin_article_comments_url(@article), polymorphic_url([:admin, @article, @comment])) + @comment.save + assert_equal(admin_article_comment_url(@article, @comment), polymorphic_url([:admin, @article, @comment])) + end end -- cgit v1.2.3