Permalink
Browse files

Ensure that engine can be mounted at root (#4314)

It's already fixed and the fix was actually in journey library,
but with #4314 it reappeared second time, so probably this
kind of integration test will be good to have to not allow it to
sneak in after changes in journey or rails itself.
  • Loading branch information...
1 parent a85714a commit 24e00e1eb7bccb479787e78bf63ae739105b72b7 @drogus drogus committed Mar 13, 2012
Showing with 54 additions and 0 deletions.
  1. +54 −0 railties/test/railties/engine_test.rb
@@ -753,6 +753,60 @@ def foo
assert_equal "Bukkit's foo partial", last_response.body.strip
end
+ test "engine can be properly mounted at root" do
+ add_to_config("config.action_dispatch.show_exceptions = false")
+ add_to_config("config.serve_static_assets = false")
+
+ @plugin.write "lib/bukkits.rb", <<-RUBY
+ module Bukkits
+ class Engine < ::Rails::Engine
+ isolate_namespace ::Bukkits
+ end
+ end
+ RUBY
+
+ @plugin.write "config/routes.rb", <<-RUBY
+ Bukkits::Engine.routes.draw do
+ root "foo#index"
+ end
+ RUBY
+
+ @plugin.write "app/controllers/bukkits/foo_controller.rb", <<-RUBY
+ module Bukkits
+ class FooController < ActionController::Base
+ def index
+ text = <<-TEXT
+ script_name: \#{request.script_name}
+ fullpath: \#{request.fullpath}
+ path: \#{request.path}
+ TEXT
+ render :text => text
+ end
+ end
+ end
+ RUBY
+
+
+ app_file "config/routes.rb", <<-RUBY
+ Rails.application.routes.draw do
+ mount Bukkits::Engine => "/"
+ end
+ RUBY
+
+ boot_rails
+ require "#{rails_root}/config/environment"
+
+ expected = <<-TEXT
+ script_name:
+ fullpath: /
+ path: /
+ TEXT
+
+ get("/")
+ assert_equal expected.split("\n").map(&:strip),
+ last_response.body.split("\n").map(&:strip)
+ end
+
private
def app
Rails.application

2 comments on commit 24e00e1

@drogus thanks! I totally missed issue #4314. I was going to ask someone to merge #5342 which showed the request.url issue, but you've already covered all possibilities here, thanks =).

Member

drogus replied Mar 13, 2012

@carlosantoniodasilva on the other hand I totally missed #5342 :P

Please sign in to comment.