aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-29 16:02:16 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-29 16:02:16 -0700
commitc767fbfc25561b1ba6a9c4ae040169826e5235b8 (patch)
tree1c0bd3ffc87cd5469a6e4e6f0fb48296cf94b15b /actionpack/test/dispatch
parentaecf76fcde37ca31d5520f49f5e238a7161869a3 (diff)
parentda2cf937aa68c2470c0d4a73c29fe3555b2667c0 (diff)
downloadrails-c767fbfc25561b1ba6a9c4ae040169826e5235b8.tar.gz
rails-c767fbfc25561b1ba6a9c4ae040169826e5235b8.tar.bz2
rails-c767fbfc25561b1ba6a9c4ae040169826e5235b8.zip
Merge branch 'mapper'
* mapper: (34 commits) no more is_a checks on instantiation Path::Pattern is instantiated internally, so make the contructor require a strexp object Strexp#names is only used in a test, so rm pass the parsed path from mapper to the Strexp add an alternate constructor to Strexp that takes a string ask the strexp for the ast remove dead code disconnect path from the instance reuse the ast we already made use a parser to extract the group parts from the path pass the parsed parameters through the methods so we don't reparse or require caching code "controllers" should be a valid path name controllers with slash names are also not supported, so we can reuse the message only validate controllers golf down a bit only error handling between controller and action is the same add a test for controllers without colons move nil check to a method that yields to a block if the value is not nil translate action / controller to the desired object only one nil check on the action variable ...
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/mapper_test.rb4
-rw-r--r--actionpack/test/dispatch/routing_test.rb32
2 files changed, 34 insertions, 2 deletions
diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb
index 58457b0c28..e3dcf9b88a 100644
--- a/actionpack/test/dispatch/mapper_test.rb
+++ b/actionpack/test/dispatch/mapper_test.rb
@@ -72,7 +72,7 @@ module ActionDispatch
mapper = Mapper.new fakeset
mapper.get '/*path/foo/:bar', :to => 'pages#show'
assert_equal '/*path/foo/:bar(.:format)', fakeset.conditions.first[:path_info]
- assert_nil fakeset.requirements.first[:path]
+ assert_equal(/.+?/, fakeset.requirements.first[:path])
end
def test_map_wildcard_with_multiple_wildcard
@@ -80,7 +80,7 @@ module ActionDispatch
mapper = Mapper.new fakeset
mapper.get '/*foo/*bar', :to => 'pages#show'
assert_equal '/*foo/*bar(.:format)', fakeset.conditions.first[:path_info]
- assert_nil fakeset.requirements.first[:foo]
+ assert_equal(/.+?/, fakeset.requirements.first[:foo])
assert_equal(/.+?/, fakeset.requirements.first[:bar])
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index c9777ae71f..d6477e19bb 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -99,6 +99,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_namespace_without_controller_segment
+ draw do
+ namespace :admin do
+ get 'hello/:controllers/:action'
+ end
+ end
+ get '/admin/hello/foo/new'
+ assert_equal 'foo', @request.params["controllers"]
+ end
+
def test_session_singleton_resource
draw do
resource :session do
@@ -3137,6 +3147,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal '/foo', foo_root_path
end
+ def test_namespace_as_controller
+ draw do
+ namespace :foo do
+ get '/', to: '/bar#index', as: 'root'
+ end
+ end
+
+ get '/foo'
+ assert_equal 'bar#index', @response.body
+ assert_equal '/foo', foo_root_path
+ end
+
def test_trailing_slash
draw do
resources :streams
@@ -3546,6 +3568,16 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
assert_match "'Admin::StorageFiles' is not a supported controller name", e.message
end
+
+ def test_warn_with_ruby_constant_syntax_no_colons
+ e = assert_raise(ArgumentError) do
+ draw do
+ resources :storage_files, :controller => 'Admin'
+ end
+ end
+
+ assert_match "'Admin' is not a supported controller name", e.message
+ end
end
class TestDefaultScope < ActionDispatch::IntegrationTest