diff options
-rw-r--r-- | actionpack/test/dispatch/mount_test.rb | 5 | ||||
-rw-r--r-- | actionpack/test/dispatch/url_generation_test.rb | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb index f7a746120e..536e35ab2e 100644 --- a/actionpack/test/dispatch/mount_test.rb +++ b/actionpack/test/dispatch/mount_test.rb @@ -37,6 +37,11 @@ class TestRoutingMount < ActionDispatch::IntegrationTest assert_equal "/sprockets -- /omg", response.body end + def test_mounting_works_with_nested_script_name + get "/foo/sprockets/omg", {}, 'SCRIPT_NAME' => '/foo', 'PATH_INFO' => '/sprockets/omg' + assert_equal "/foo/sprockets -- /omg", response.body + end + def test_mounting_works_with_scope get "/its_a/sprocket/omg" assert_equal "/its_a/sprocket -- /omg", response.body diff --git a/actionpack/test/dispatch/url_generation_test.rb b/actionpack/test/dispatch/url_generation_test.rb index 985ff2e81a..e56e8ddc57 100644 --- a/actionpack/test/dispatch/url_generation_test.rb +++ b/actionpack/test/dispatch/url_generation_test.rb @@ -3,7 +3,7 @@ require 'abstract_unit' module TestUrlGeneration class WithMountPoint < ActionDispatch::IntegrationTest Routes = ActionDispatch::Routing::RouteSet.new - Routes.draw { get "/foo", :to => "my_route_generating#index", :as => :foo } + include Routes.url_helpers class ::MyRouteGeneratingController < ActionController::Base include Routes.url_helpers @@ -12,7 +12,11 @@ module TestUrlGeneration end end - include Routes.url_helpers + Routes.draw do + get "/foo", :to => "my_route_generating#index", :as => :foo + + mount MyRouteGeneratingController.action(:index), at: '/bar' + end def _routes Routes @@ -30,11 +34,16 @@ module TestUrlGeneration assert_equal "/bar/foo", foo_path(:script_name => "/bar") end - test "the request's SCRIPT_NAME takes precedence over the routes'" do + test "the request's SCRIPT_NAME takes precedence over the route" do get "/foo", {}, 'SCRIPT_NAME' => "/new", 'action_dispatch.routes' => Routes assert_equal "/new/foo", response.body end + test "the request's SCRIPT_NAME wraps the mounted app's" do + get '/new/bar/foo', {}, 'SCRIPT_NAME' => '/new', 'PATH_INFO' => '/bar/foo', 'action_dispatch.routes' => Routes + assert_equal "/new/bar/foo", response.body + end + test "handling http protocol with https set" do https! assert_equal "http://www.example.com/foo", foo_url(:protocol => "http") |