aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-06-03 18:12:56 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-06-03 18:12:56 -0500
commit885453537e550489f825356ec4404d384893126a (patch)
tree215184057efd4202059b8512bcbcd159962ff9a4
parentedfa195e2ace7b4fb8195333c6e44e6bf8986c11 (diff)
parent025515b234d8380f195e3de3818d076302605b12 (diff)
downloadrails-885453537e550489f825356ec4404d384893126a.tar.gz
rails-885453537e550489f825356ec4404d384893126a.tar.bz2
rails-885453537e550489f825356ec4404d384893126a.zip
Merge branch 'master' of git@github.com:rails/rails
-rw-r--r--actionpack/lib/action_controller/assertions/response_assertions.rb2
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb23
2 files changed, 21 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index c5fc6c7966..3deda0b45a 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -97,7 +97,7 @@ module ActionController
value['controller'] = value['controller'].to_s
if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
- value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path)
+ value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash)
end
value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash
end
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index f152b1d19c..c25e9e1df6 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -137,6 +137,9 @@ class AssertResponseWithUnexpectedErrorController < ActionController::Base
end
end
+class UserController < ActionController::Base
+end
+
module Admin
class InnerModuleController < ActionController::Base
def index
@@ -174,7 +177,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
# let's get this party started
def setup
ActionController::Routing::Routes.reload
- ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module content admin/user))
+ ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user))
@controller = ActionPackAssertionsController.new
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
end
@@ -268,7 +271,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
assert_redirected_to admin_inner_module_path
end
end
-
+
def test_assert_redirected_to_top_level_named_route_from_nested_controller
with_routing do |set|
set.draw do |map|
@@ -277,11 +280,25 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
end
@controller = Admin::InnerModuleController.new
process :redirect_to_top_level_named_route
- # passes -> assert_redirected_to "http://test.host/action_pack_assertions/foo"
+ # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return
assert_redirected_to "/action_pack_assertions/foo"
end
end
+ def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces
+ with_routing do |set|
+ set.draw do |map|
+ # this controller exists in the admin namespace as well which is the only difference from previous test
+ map.top_level '/user/:id', :controller => 'user', :action => 'index'
+ map.connect ':controller/:action/:id'
+ end
+ @controller = Admin::InnerModuleController.new
+ process :redirect_to_top_level_named_route
+ # assert_redirected_to top_level_url('foo') would pass because of exact match early return
+ assert_redirected_to top_level_path('foo')
+ end
+ end
+
# -- standard request/response object testing --------------------------------
# make sure that the template objects exist