aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-08 12:24:49 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-08 12:26:18 -0800
commitf38e2e03351da463f84f6850fa10718ece98ff26 (patch)
tree811e4c92409f491646dcf1f969747d4e448bb0f3 /actionpack/test/dispatch
parent7942e909608f24db0365943c5d9ad51cbb4d27b5 (diff)
downloadrails-f38e2e03351da463f84f6850fa10718ece98ff26.tar.gz
rails-f38e2e03351da463f84f6850fa10718ece98ff26.tar.bz2
rails-f38e2e03351da463f84f6850fa10718ece98ff26.zip
Add support for mount RackApp, :at => "/sprockets" with a shorthand of mount Sprockets => "/sprockets".
This is different from the match syntax in that it cannot be used for controller/action and it does not assume an anchor at the end of the match. For instance, in the above example, if the client asked for "/sprockets/foo.js", the Sprockets app would have a SCRIPT_NAME of "/sprockets" and PATH_INFO of "/foo.js".
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/mount_test.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb
new file mode 100644
index 0000000000..f89e5fda07
--- /dev/null
+++ b/actionpack/test/dispatch/mount_test.rb
@@ -0,0 +1,36 @@
+require 'abstract_unit'
+
+class TestRoutingMount < ActionDispatch::IntegrationTest
+ SprocketsApp = lambda { |env|
+ [200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]]
+ }
+
+ Router = ActionDispatch::Routing::RouteSet.new
+ Router.draw do
+ mount SprocketsApp, :at => "/sprockets"
+ mount SprocketsApp => "/shorthand"
+
+ scope "/its_a" do
+ mount SprocketsApp, :at => "/sprocket"
+ end
+ end
+
+ def app
+ Router
+ end
+
+ def test_mounting_sets_script_name
+ get "/sprockets/omg"
+ assert_equal "/sprockets -- /omg", response.body
+ end
+
+ def test_mounting_works_with_scope
+ get "/its_a/sprocket/omg"
+ assert_equal "/its_a/sprocket -- /omg", response.body
+ end
+
+ def test_mounting_with_shorthand
+ get "/shorthand/omg"
+ assert_equal "/shorthand -- /omg", response.body
+ end
+end \ No newline at end of file