blob: 326b336a1a7020da5fc329b057a81e7577ac0748 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
require 'abstract_unit'
module TestUrlGeneration
class WithMountPoint < ActionDispatch::IntegrationTest
Router = ActionDispatch::Routing::RouteSet.new
Router.draw { match "/foo", :to => "my_route_generating#index", :as => :foo }
class ::MyRouteGeneratingController < ActionController::Base
include Router.url_helpers
def index
render :text => foo_path
end
end
include Router.url_helpers
def _router
Router
end
def app
Router
end
test "generating URLS normally" do
assert_equal "/foo", foo_path
end
test "accepting a :script_name option" do
assert_equal "/bar/foo", foo_path(:script_name => "/bar")
end
test "the request's SCRIPT_NAME takes precedence over the router's" do
get "/foo", {}, 'SCRIPT_NAME' => "/new"
assert_equal "/new/foo", response.body
end
test "handling http protocol with https set" do
https!
assert_equal "http://www.example.com/foo", foo_url(:protocol => "http")
end
end
end
|