diff options
Diffstat (limited to 'actionpack/test/dispatch')
| -rw-r--r-- | actionpack/test/dispatch/header_test.rb | 6 | ||||
| -rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 42 |
2 files changed, 48 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/header_test.rb b/actionpack/test/dispatch/header_test.rb index 7a155d70cb..374e618b42 100644 --- a/actionpack/test/dispatch/header_test.rb +++ b/actionpack/test/dispatch/header_test.rb @@ -158,4 +158,10 @@ class HeaderTest < ActiveSupport::TestCase assert_equal({ "HTTP_REFERER"=>"http://example.com/", "CONTENT_TYPE"=>"text/plain" }, env) end + + test "fetch exception" do + assert_raises KeyError do + @headers.fetch(:some_key_that_doesnt_exist) + end + end end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index ee5c30ef0e..0938460632 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -3669,6 +3669,48 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_multiple_roots + draw do + namespace :foo do + root "pages#index", constraints: { host: 'www.example.com' } + root "admin/pages#index", constraints: { host: 'admin.example.com' } + end + + root "pages#index", constraints: { host: 'www.example.com' } + root "admin/pages#index", constraints: { host: 'admin.example.com' } + end + + get "http://www.example.com/foo" + assert_equal "foo/pages#index", @response.body + + get "http://admin.example.com/foo" + assert_equal "foo/admin/pages#index", @response.body + + get "http://www.example.com/" + assert_equal "pages#index", @response.body + + get "http://admin.example.com/" + assert_equal "admin/pages#index", @response.body + end + + def test_namespaced_roots + draw do + namespace :foo do + root "test#index" + end + + root "test#index" + + namespace :bar do + root "test#index" + end + end + + assert_equal "/foo", foo_root_path + assert_equal "/", root_path + assert_equal "/bar", bar_root_path + end + private def draw(&block) |
