Permalink
Browse files

Adding test case for request.url in engine mounted at root (#2131)

  • Loading branch information...
1 parent abe6105 commit 8cf20ff57713df4d5a977194296538f4e669e302 @guilleiguaran committed Jul 24, 2011
Showing with 30 additions and 0 deletions.
  1. +30 −0 railties/test/railties/mounted_engine_test.rb
@@ -11,10 +11,12 @@ def setup
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'
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"
@@ -26,6 +28,29 @@ def setup
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"
+ 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
@@ -173,5 +198,10 @@ def script_name(script_name)
get "/polymorphic_route"
assert_equal "http://example.org/anonymous/blog/posts/44", 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

0 comments on commit 8cf20ff

Please sign in to comment.