diff options
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 33 | ||||
-rw-r--r-- | actionpack/test/dispatch/url_generation_test.rb | 7 |
2 files changed, 36 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index f5fcf9b0df..87a46feec7 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -18,10 +18,9 @@ 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 @@ -34,6 +33,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}" } @@ -121,6 +122,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest match 'articles/:year/:month/:day/:title', :to => "articles#show", :as => :article namespace :account do + match 'shorthand' match 'description', :to => "account#description", :as => "description" resource :subscription, :credit, :credit_card @@ -193,6 +195,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 @@ -654,6 +657,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' 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 |