diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-11-22 16:31:00 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-11-22 16:31:00 +0000 |
commit | d1529a71d120a8533f7e042b8e92698428c7a3a1 (patch) | |
tree | 0d5453e026d1fe77b7c8d37313a3ebe2681c1a88 /actionpack | |
parent | a2e826dc0f32647d8e4ae68214d717a5f3fc15df (diff) | |
download | rails-d1529a71d120a8533f7e042b8e92698428c7a3a1.tar.gz rails-d1529a71d120a8533f7e042b8e92698428c7a3a1.tar.bz2 rails-d1529a71d120a8533f7e042b8e92698428c7a3a1.zip |
Update Routing to complain when :controller is not specified by a route. Closes #6669.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5607 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/url_rewriter_test.rb | 4 |
4 files changed, 14 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index ed13fa1359..39bfc0fb06 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Update Routing to complain when :controller is not specified by a route. Closes #6669. [Nicholas Seckar] + * Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim] * Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. #6651 [Jeff Barczewski] diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 3c53acc164..2fe74c5b34 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -950,6 +950,10 @@ module ActionController route.significant_keys << :action end + if !route.significant_keys.include?(:controller) + raise ArgumentError, "Illegal route: the :controller must be specified!" + end + route end end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index cfba8fb976..18fcef5bc5 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -853,6 +853,12 @@ class RouteTest < Test::Unit::TestCase { :controller => "users", :action => "show", :format => "html" }, route.defaults) end + + def test_builder_complains_without_controller + assert_raises(ArgumentError) do + ROUTING::RouteBuilder.new.build '/contact', :contoller => "contact", :action => "index" + end + end def test_significant_keys_for_default_route keys = default_route.significant_keys.sort_by {|k| k.to_s } diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index 53cd278b6b..882add496f 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -78,7 +78,7 @@ class UrlWriterTests < Test::Unit::TestCase def test_named_route ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user' + map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' map.connect ':controller/:action/:id' end @@ -96,7 +96,7 @@ class UrlWriterTests < Test::Unit::TestCase def test_only_path ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user' + map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' map.connect ':controller/:action/:id' end |