aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/railties/mounted_engine_test.rb
diff options
context:
space:
mode:
authorrails-noob <rails-noob@github.com>2011-08-23 18:01:02 +0000
committerrails-noob <rails-noob@github.com>2011-09-06 15:26:19 +0000
commit43fbb1e6b822c54568cb762a435c9cfb3f97cdeb (patch)
treecb013be1e0cc5796239a5061ae8c599ede16ecbc /railties/test/railties/mounted_engine_test.rb
parentcc90adfd2a171c5fc9f90f6a6506c5ac937efab3 (diff)
downloadrails-43fbb1e6b822c54568cb762a435c9cfb3f97cdeb.tar.gz
rails-43fbb1e6b822c54568cb762a435c9cfb3f97cdeb.tar.bz2
rails-43fbb1e6b822c54568cb762a435c9cfb3f97cdeb.zip
Fix bug #2579.
Avoids double slash at start of paths when mounting an engine at the root.
Diffstat (limited to 'railties/test/railties/mounted_engine_test.rb')
-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