aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-05-07 14:53:57 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-05-07 14:53:57 -0700
commit4d0e6db9ec7537401d05f523ba8b29955f84f846 (patch)
tree8ab1b1f9716b02b6f79d682042f9fe766b560d40
parented2feb7962bd97c2222ba609bb01fe5165a597c8 (diff)
downloadrails-4d0e6db9ec7537401d05f523ba8b29955f84f846.tar.gz
rails-4d0e6db9ec7537401d05f523ba8b29955f84f846.tar.bz2
rails-4d0e6db9ec7537401d05f523ba8b29955f84f846.zip
Add passing tests for generating URLs with nested SCRIPT_NAMEs
-rw-r--r--actionpack/test/dispatch/mount_test.rb5
-rw-r--r--actionpack/test/dispatch/url_generation_test.rb15
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")