aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/railties
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-09-06 09:10:39 -0700
committerSantiago Pastorino <santiago@wyeworks.com>2011-09-06 09:10:39 -0700
commitef14a0ec8647010eed3a8006409739e6d42791a9 (patch)
treecd496b019481f666401ec65c581af55fdeffdc9a /railties/test/railties
parent1e61f2603caaa2e608294b6e563fd2251e349eda (diff)
parent43fbb1e6b822c54568cb762a435c9cfb3f97cdeb (diff)
downloadrails-ef14a0ec8647010eed3a8006409739e6d42791a9.tar.gz
rails-ef14a0ec8647010eed3a8006409739e6d42791a9.tar.bz2
rails-ef14a0ec8647010eed3a8006409739e6d42791a9.zip
Merge pull request #2577 from rails-noob/master
Fix double slash at start of paths when mounting an engine at the root.
Diffstat (limited to 'railties/test/railties')
-rw-r--r--railties/test/railties/mounted_engine_test.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index 94dec405a7..253e61259b 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -11,13 +11,17 @@ module ApplicationTests
add_to_config("config.action_dispatch.show_exceptions = false")
+ @simple_plugin = engine "weblog"
@plugin = engine "blog"
app_file 'config/routes.rb', <<-RUBY
AppTemplate::Application.routes.draw do
+ mount Weblog::Engine, :at => '/', :as => 'weblog'
resources :posts
match "/engine_route" => "application_generating#engine_route"
match "/engine_route_in_view" => "application_generating#engine_route_in_view"
+ match "/weblog_engine_route" => "application_generating#weblog_engine_route"
+ match "/weblog_engine_route_in_view" => "application_generating#weblog_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"
@@ -28,6 +32,29 @@ module ApplicationTests
end
RUBY
+
+ @simple_plugin.write "lib/weblog.rb", <<-RUBY
+ module Weblog
+ class Engine < ::Rails::Engine
+ end
+ end
+ RUBY
+
+ @simple_plugin.write "config/routes.rb", <<-RUBY
+ Weblog::Engine.routes.draw do
+ match '/weblog' => "weblogs#index", :as => 'weblogs'
+ end
+ RUBY
+
+ @simple_plugin.write "app/controllers/weblogs_controller.rb", <<-RUBY
+ class WeblogsController < ActionController::Base
+ def index
+ render :text => request.url
+ end
+ end
+ RUBY
+
+
@plugin.write "app/models/blog/post.rb", <<-RUBY
module Blog
class Post
@@ -100,6 +127,14 @@ module ApplicationTests
render :inline => "<%= blog.posts_path %>"
end
+ def weblog_engine_route
+ render :text => weblog.weblogs_path
+ end
+
+ def weblog_engine_route_in_view
+ render :inline => "<%= weblog.weblogs_path %>"
+ end
+
def url_for_engine_route
render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true)
end
@@ -192,5 +227,18 @@ module ApplicationTests
get "/application_polymorphic_path"
assert_equal "/posts/44", last_response.body
end
+
+ test "route path for controller action when engine is mounted at root" do
+ get "/weblog_engine_route"
+ assert_equal "/weblog", last_response.body
+
+ get "/weblog_engine_route_in_view"
+ assert_equal "/weblog", last_response.body
+ end
+
+ test "request url for controller action when engine is mounted at root" do
+ get "/weblog"
+ assert_equal "http://example.org/weblog", last_response.body
+ end
end
end