Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Routing to complain when :controller is not specified by a rou…

…te. Closes #6669.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5607 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d1529a71d120a8533f7e042b8e92698428c7a3a1 1 parent a2e826d
@seckar seckar authored
View
2  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]
View
4 actionpack/lib/action_controller/routing.rb
@@ -950,6 +950,10 @@ def build(path, options)
route.significant_keys << :action
end
+ if !route.significant_keys.include?(:controller)
+ raise ArgumentError, "Illegal route: the :controller must be specified!"
+ end
+
route
end
end
View
6 actionpack/test/controller/routing_test.rb
@@ -853,6 +853,12 @@ def test_defaults
{ :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 }
View
4 actionpack/test/controller/url_rewriter_test.rb
@@ -78,7 +78,7 @@ def test_protocol
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 @@ def test_named_route
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
Please sign in to comment.
Something went wrong with that request. Please try again.