aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-08-25 15:42:24 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:13 +0200
commit613cbe1f0075eed7ebf1ac521e99f652f6891330 (patch)
tree01b4f20ac67436817b4f5b3da0ccf43ae1f35cc5 /railties
parent16dcaf83681d9d84c26cfab23249a6f069ca5c08 (diff)
downloadrails-613cbe1f0075eed7ebf1ac521e99f652f6891330.tar.gz
rails-613cbe1f0075eed7ebf1ac521e99f652f6891330.tar.bz2
rails-613cbe1f0075eed7ebf1ac521e99f652f6891330.zip
Add possibility to explicitly call engine's routes through polymorphic_routes, for example: polymorphic_url([blog, @post])
Diffstat (limited to 'railties')
-rw-r--r--railties/test/railties/mounted_engine_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index be5bb30a9a..1df6326d26 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -18,6 +18,7 @@ module ApplicationTests
match "/engine_route" => "application_generating#engine_route"
match "/engine_route_in_view" => "application_generating#engine_route_in_view"
match "/url_for_engine_route" => "application_generating#url_for_engine_route"
+ match "/polymorphic_route" => "application_generating#polymorphic_route"
scope "/:user", :user => "anonymous" do
mount Blog::Engine => "/blog"
end
@@ -25,6 +26,26 @@ module ApplicationTests
end
RUBY
+ @plugin.write "app/models/blog/post.rb", <<-RUBY
+ module Blog
+ class Post
+ extend ActiveModel::Naming
+
+ def id
+ 44
+ end
+
+ def to_param
+ id.to_s
+ end
+
+ def new_record?
+ false
+ end
+ end
+ end
+ RUBY
+
@plugin.write "lib/blog.rb", <<-RUBY
module Blog
class Engine < ::Rails::Engine
@@ -78,6 +99,10 @@ module ApplicationTests
def url_for_engine_route
render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true)
end
+
+ def polymorphic_route
+ render :text => polymorphic_url([blog, Blog::Post.new])
+ end
end
RUBY
@@ -141,6 +166,11 @@ module ApplicationTests
script_name "/foo"
get "/someone/blog/generate_application_route", {}, 'SCRIPT_NAME' => '/foo'
assert_equal "/foo/", last_response.body
+ reset_script_name!
+
+ # test polymorphic routes
+ get "/polymorphic_route"
+ assert_equal "http://example.org/anonymous/blog/posts/44", last_response.body
end
end
end