From 24e00e1eb7bccb479787e78bf63ae739105b72b7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 13 Mar 2012 20:04:41 +0100 Subject: 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. --- railties/test/railties/engine_test.rb | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'railties') diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 5ed923a484..36de773633 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -753,6 +753,60 @@ module RailtiesTest 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 -- cgit v1.2.3