aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorthedarkone <thedarkone2@gmail.com>2011-06-06 14:13:06 +0200
committerthedarkone <thedarkone2@gmail.com>2011-07-25 13:43:02 +0200
commit036f77574d5cd095b9ea78e2fd927c8d7764bd31 (patch)
treece5f8e923f5acee297bfdacd3d6bd271f5c90339 /railties/test
parent02691d3516e68b2de5545ec7a495024a377f89fc (diff)
downloadrails-036f77574d5cd095b9ea78e2fd927c8d7764bd31.tar.gz
rails-036f77574d5cd095b9ea78e2fd927c8d7764bd31.tar.bz2
rails-036f77574d5cd095b9ea78e2fd927c8d7764bd31.zip
Make polymorphic_url calls go through application helpers again.
This brings back the ability to overwrite/extend url generating methods in application heleprs.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/railties/mounted_engine_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index b793a7401f..94dec405a7 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -15,10 +15,12 @@ module ApplicationTests
app_file 'config/routes.rb', <<-RUBY
AppTemplate::Application.routes.draw do
+ resources :posts
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"
+ match "/application_polymorphic_path" => "application_generating#application_polymorphic_path"
scope "/:user", :user => "anonymous" do
mount Blog::Engine => "/blog"
end
@@ -59,6 +61,7 @@ module ApplicationTests
resources :posts
match '/generate_application_route', :to => 'posts#generate_application_route'
match '/application_route_in_view', :to => 'posts#application_route_in_view'
+ match '/engine_polymorphic_path', :to => 'posts#engine_polymorphic_path'
end
RUBY
@@ -79,6 +82,10 @@ module ApplicationTests
def application_route_in_view
render :inline => "<%= main_app.root_path %>"
end
+
+ def engine_polymorphic_path
+ render :text => polymorphic_path(Post.new)
+ end
end
end
RUBY
@@ -100,6 +107,10 @@ module ApplicationTests
def polymorphic_route
render :text => polymorphic_url([blog, Blog::Post.new])
end
+
+ def application_polymorphic_path
+ render :text => polymorphic_path(Blog::Post.new)
+ end
end
RUBY
@@ -172,6 +183,14 @@ module ApplicationTests
# test polymorphic routes
get "/polymorphic_route"
assert_equal "http://example.org/anonymous/blog/posts/44", last_response.body
+
+ # test that correct path is generated for the same polymorphic_path call in an engine
+ get "/somone/blog/engine_polymorphic_path"
+ assert_equal "/somone/blog/posts/44", last_response.body
+
+ # and in an application
+ get "/application_polymorphic_path"
+ assert_equal "/posts/44", last_response.body
end
end
end