aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb31
1 files changed, 28 insertions, 3 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index c4b0b9cdbf..32e2717789 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -29,6 +29,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match 'account/modulo/:name', :to => redirect("/%{name}s")
match 'account/proc/:name', :to => redirect {|params| "/#{params[:name].pluralize}" }
+ match 'account/google' => redirect('http://www.google.com/')
match 'openid/login', :via => [:get, :post], :to => "openid#login"
@@ -65,7 +66,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
resources :people do
nested do
- namespace ":access_token" do
+ scope "/:access_token" do
resource :avatar
end
end
@@ -432,12 +433,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
with_test_routes do
get '/account/subscription'
assert_equal 'subscriptions#show', @response.body
+ assert_equal '/account/subscription', account_subscription_path
get '/account/credit'
assert_equal 'credits#show', @response.body
+ assert_equal '/account/credit', account_credit_path
get '/account/credit_card'
assert_equal 'credit_cards#show', @response.body
+ assert_equal '/account/credit_card', account_credit_card_path
end
end
@@ -472,7 +476,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'projects#index', @response.body
end
end
-
+
def test_index
with_test_routes do
assert_equal '/info', info_path
@@ -488,7 +492,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'projects#info', @response.body
end
end
-
+
def test_convention_match_with_no_scope
with_test_routes do
assert_equal '/account/overview', account_overview_path
@@ -497,6 +501,27 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_redirect_with_complete_url
+ with_test_routes do
+ get '/account/google'
+ assert_equal 301, @response.status
+ assert_equal 'http://www.google.com/', @response.headers['Location']
+ assert_equal 'Moved Permanently', @response.body
+ end
+ end
+
+ def test_redirect_with_port
+ previous_host, self.host = self.host, 'www.example.com:3000'
+ with_test_routes do
+ get '/account/login'
+ assert_equal 301, @response.status
+ assert_equal 'http://www.example.com:3000/login', @response.headers['Location']
+ assert_equal 'Moved Permanently', @response.body
+ end
+ ensure
+ self.host = previous_host
+ end
+
private
def with_test_routes
real_routes, temp_routes = ActionController::Routing::Routes, Routes