2010-03-05 00:59:42 -05:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
module TestUrlGeneration
|
|
|
|
class WithMountPoint < ActionDispatch::IntegrationTest
|
2010-07-01 18:29:20 -04:00
|
|
|
Routes = ActionDispatch::Routing::RouteSet.new
|
|
|
|
Routes.draw { match "/foo", :to => "my_route_generating#index", :as => :foo }
|
2010-03-05 00:59:42 -05:00
|
|
|
|
|
|
|
class ::MyRouteGeneratingController < ActionController::Base
|
2010-07-01 18:29:20 -04:00
|
|
|
include Routes.url_helpers
|
2010-03-05 00:59:42 -05:00
|
|
|
def index
|
|
|
|
render :text => foo_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-07-01 18:29:20 -04:00
|
|
|
include Routes.url_helpers
|
2010-03-05 00:59:42 -05:00
|
|
|
|
2010-07-01 18:29:20 -04:00
|
|
|
def _routes
|
|
|
|
Routes
|
2010-03-05 00:59:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def app
|
2010-07-01 18:29:20 -04:00
|
|
|
Routes
|
2010-03-05 00:59:42 -05:00
|
|
|
end
|
|
|
|
|
2010-03-05 01:17:25 -05:00
|
|
|
test "generating URLS normally" do
|
|
|
|
assert_equal "/foo", foo_path
|
2010-03-05 00:59:42 -05:00
|
|
|
end
|
|
|
|
|
2010-03-05 01:17:25 -05:00
|
|
|
test "accepting a :script_name option" do
|
2010-03-05 00:59:42 -05:00
|
|
|
assert_equal "/bar/foo", foo_path(:script_name => "/bar")
|
|
|
|
end
|
|
|
|
|
2010-07-01 18:29:20 -04:00
|
|
|
test "the request's SCRIPT_NAME takes precedence over the routes'" do
|
2010-07-08 19:22:18 -04:00
|
|
|
get "/foo", {}, 'SCRIPT_NAME' => "/new", 'action_dispatch.routes' => Routes
|
2010-03-05 00:59:42 -05:00
|
|
|
assert_equal "/new/foo", response.body
|
|
|
|
end
|
2010-03-15 22:26:58 -04:00
|
|
|
|
|
|
|
test "handling http protocol with https set" do
|
|
|
|
https!
|
2010-03-16 01:44:49 -04:00
|
|
|
assert_equal "http://www.example.com/foo", foo_url(:protocol => "http")
|
2010-03-15 22:26:58 -04:00
|
|
|
end
|
2010-03-05 00:59:42 -05:00
|
|
|
end
|
2010-03-15 22:26:58 -04:00
|
|
|
end
|
2010-07-13 18:46:42 -04:00
|
|
|
|