aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2015-10-07 22:25:39 +0100
committerAndrew White <pixeltrix@users.noreply.github.com>2015-10-07 22:25:39 +0100
commitfef1064052aeda3701913d3171f17fd4fc84d3f0 (patch)
tree5fdea0860cdbb8fc383a25e67e66877ad9542abe /railties/test
parent54f3a18eeceb12c99a7a7463048cd13ee6a51778 (diff)
parentbcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5 (diff)
downloadrails-fef1064052aeda3701913d3171f17fd4fc84d3f0.tar.gz
rails-fef1064052aeda3701913d3171f17fd4fc84d3f0.tar.bz2
rails-fef1064052aeda3701913d3171f17fd4fc84d3f0.zip
Merge pull request #21804 from merhard/mounted_engine_route_fix
Mounted engine route fix
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/railties/engine_test.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 79bd7a8241..2c82f728ee 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -1304,6 +1304,55 @@ YAML
assert_equal '/foo/bukkits/bukkit', last_response.body
end
+ test "paths are properly generated when application is mounted at sub-path and relative_url_root is set" do
+ add_to_config "config.relative_url_root = '/foo'"
+
+ @plugin.write "lib/bukkits.rb", <<-RUBY
+ module Bukkits
+ class Engine < ::Rails::Engine
+ isolate_namespace Bukkits
+ end
+ end
+ RUBY
+
+ app_file "app/controllers/bar_controller.rb", <<-RUBY
+ class BarController < ApplicationController
+ def index
+ render text: bukkits.bukkit_path
+ end
+ end
+ RUBY
+
+ app_file "config/routes.rb", <<-RUBY
+ Rails.application.routes.draw do
+ get '/bar' => 'bar#index', :as => 'bar'
+ mount Bukkits::Engine => "/bukkits", :as => "bukkits"
+ end
+ RUBY
+
+ @plugin.write "config/routes.rb", <<-RUBY
+ Bukkits::Engine.routes.draw do
+ get '/bukkit' => 'bukkit#index'
+ end
+ RUBY
+
+ @plugin.write "app/controllers/bukkits/bukkit_controller.rb", <<-RUBY
+ class Bukkits::BukkitController < ActionController::Base
+ def index
+ render text: main_app.bar_path
+ end
+ end
+ RUBY
+
+ boot_rails
+
+ get("/bukkits/bukkit", {}, {'SCRIPT_NAME' => '/foo'})
+ assert_equal '/foo/bar', last_response.body
+
+ get("/bar", {}, {'SCRIPT_NAME' => '/foo'})
+ assert_equal '/foo/bukkits/bukkit', last_response.body
+ end
+
private
def app
Rails.application