Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for mount RackApp, :at => "/sprockets" with a shorthand o…
…f 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".
- Loading branch information
Carlhuda
committed
Mar 8, 2010
1 parent
7942e90
commit f38e2e0
Showing
4 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |