diff options
author | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-11-20 13:16:39 -0500 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-11-20 14:55:47 -0500 |
commit | dde9c488398293fb1cbdc02595b8c4e9860b03cc (patch) | |
tree | 449385b6004d6c3d91f41b2e0eb8e990fc97ee0f /actionpack/test/dispatch/routing_test.rb | |
parent | 023a840f5f10c5a611a0618ff8ea9e16cd771f93 (diff) | |
download | rails-dde9c488398293fb1cbdc02595b8c4e9860b03cc.tar.gz rails-dde9c488398293fb1cbdc02595b8c4e9860b03cc.tar.bz2 rails-dde9c488398293fb1cbdc02595b8c4e9860b03cc.zip |
Raise an error on root route naming conflicts.
Raises an ArgumentError when multiple root routes are defined in the
same context instead of assigning nil names to subsequent roots.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index affc2d8497..4dffbd0db1 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -3698,15 +3698,25 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end - def test_multiple_roots + def test_multiple_roots_raises_error + ex = assert_raises(ArgumentError) { + draw do + root "pages#index", constraints: { host: "www.example.com" } + root "admin/pages#index", constraints: { host: "admin.example.com" } + end + } + assert_match(/Invalid route name, already in use: 'root'/, ex.message) + end + + def test_multiple_named_roots draw do namespace :foo do root "pages#index", constraints: { host: "www.example.com" } - root "admin/pages#index", constraints: { host: "admin.example.com" } + root "admin/pages#index", constraints: { host: "admin.example.com" }, as: :admin_root end root "pages#index", constraints: { host: "www.example.com" } - root "admin/pages#index", constraints: { host: "admin.example.com" } + root "admin/pages#index", constraints: { host: "admin.example.com" }, as: :admin_root end get "http://www.example.com/foo" |