aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/routing.rb4
-rw-r--r--actionpack/test/controller/routing_test.rb6
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb4
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