aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
commitb4c91de9462f59d6395c7c871aafa3301afdc383 (patch)
treefadcaf603a6f473e8ccd52070a1f3b4f957c34cb /actionpack/test/dispatch
parent4b4f69b9bfbd33556e23262f57cf6d944dfd9f63 (diff)
parent66d57d7ba83df52ff1e0485c89f6192c2f84c6b8 (diff)
downloadrails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.gz
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.bz2
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/routing_test.rb58
-rw-r--r--actionpack/test/dispatch/url_generation_test.rb7
2 files changed, 61 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index f5fcf9b0df..c4e71a8689 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -18,14 +18,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
default_url_options :host => "rubyonrails.org"
controller :sessions do
- get 'login' => :new, :as => :login
+ get 'login' => :new
post 'login' => :create
-
- delete 'logout' => :destroy, :as => :logout
+ delete 'logout' => :destroy
end
resource :session do
get :create
+ post :reset
resource :info
end
@@ -34,6 +34,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match 'account/login', :to => redirect("/login")
match 'account/overview'
+ match '/account/nested/overview'
+ match 'sign_in' => "sessions#new"
match 'account/modulo/:name', :to => redirect("/%{name}s")
match 'account/proc/:name', :to => redirect {|params| "/#{params[:name].pluralize}" }
@@ -120,7 +122,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
# misc
match 'articles/:year/:month/:day/:title', :to => "articles#show", :as => :article
+ # default params
+ match 'inline_pages/(:id)', :to => 'pages#show', :id => 'home'
+ match 'default_pages/(:id)', :to => 'pages#show', :defaults => { :id => 'home' }
+ defaults :id => 'home' do
+ match 'scoped_pages/(:id)', :to => 'pages#show'
+ end
+
namespace :account do
+ match 'shorthand'
match 'description', :to => "account#description", :as => "description"
resource :subscription, :credit, :credit_card
@@ -193,6 +203,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal '/login', url_for(:controller => 'sessions', :action => 'new', :only_path => true)
assert_equal 'http://rubyonrails.org/login', Routes.url_for(:controller => 'sessions', :action => 'create')
+ assert_equal 'http://rubyonrails.org/login', Routes.url_helpers.login_url
end
end
@@ -237,6 +248,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get '/session/edit'
assert_equal 'sessions#edit', @response.body
assert_equal '/session/edit', edit_session_path
+
+ post '/session/reset'
+ assert_equal 'sessions#reset', @response.body
+ assert_equal '/session/reset', reset_session_path
end
end
@@ -654,6 +669,30 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_convention_match_inside_namespace
+ with_test_routes do
+ assert_equal '/account/shorthand', account_shorthand_path
+ get '/account/shorthand'
+ assert_equal 'account#shorthand', @response.body
+ end
+ end
+
+ def test_convention_match_nested_and_with_leading_slash
+ with_test_routes do
+ assert_equal '/account/nested/overview', account_nested_overview_path
+ get '/account/nested/overview'
+ assert_equal 'account/nested#overview', @response.body
+ end
+ end
+
+ def test_convention_with_explicit_end
+ with_test_routes do
+ get '/sign_in'
+ assert_equal 'sessions#new', @response.body
+ assert_equal '/sign_in', sign_in_path
+ end
+ end
+
def test_redirect_with_complete_url
with_test_routes do
get '/account/google'
@@ -742,6 +781,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_default_params
+ with_test_routes do
+ get '/inline_pages'
+ assert_equal 'home', @request.params[:id]
+
+ get '/default_pages'
+ assert_equal 'home', @request.params[:id]
+
+ get '/scoped_pages'
+ assert_equal 'home', @request.params[:id]
+ end
+ end
+
private
def with_test_routes
yield
diff --git a/actionpack/test/dispatch/url_generation_test.rb b/actionpack/test/dispatch/url_generation_test.rb
index 18b5b7ee00..326b336a1a 100644
--- a/actionpack/test/dispatch/url_generation_test.rb
+++ b/actionpack/test/dispatch/url_generation_test.rb
@@ -34,5 +34,10 @@ module TestUrlGeneration
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 \ No newline at end of file
+end