Skip to content
Browse files

apply [5785] to 1.2 branch

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5788 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1fb2f21 commit 3054a742df73a90fd3d558f1e1f473b46f224f75 @technoweenie technoweenie committed Dec 25, 2006
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.13.0 RC2*
+* Fix assert_redirected_to bug where redirecting from a nested to to a top-level controller incorrectly added the current controller's nesting. Closes #6128. [Rick Olson]
+
* Ensure render :json => ... skips the layout. #6808 [Josh Peek]
* Silence log_error deprecation warnings from inspecting deprecated instance variables. [Nate Wiger]
View
3 actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -70,7 +70,8 @@ def assert_redirected_to(options = {}, message=nil)
if value.respond_to?(:[]) && value['controller']
if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
- value['controller'] = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
+ 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)
end
value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash
end
View
23 actionpack/test/controller/action_pack_assertions_test.rb
@@ -139,6 +139,10 @@ def redirect_to_absolute_controller
def redirect_to_fellow_controller
redirect_to :controller => 'user'
end
+
+ def redirect_to_top_level_named_route
+ redirect_to top_level_url(:id => "foo")
+ end
end
end
@@ -155,10 +159,16 @@ def redirect_to_fellow_controller
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))
@controller = ActionPackAssertionsController.new
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
end
+ def teardown
+ ActionController::Routing::Routes.reload
+ end
+
# -- assertion-based testing ------------------------------------------------
def test_assert_tag_and_url_for
@@ -295,6 +305,19 @@ def test_assert_redirect_to_nested_named_route
end
end
+ def test_assert_redirected_to_top_level_named_route_from_nested_controller
+ with_routing do |set|
+ set.draw do |map|
+ map.top_level '/action_pack_assertions/:id', :controller => 'action_pack_assertions', :action => 'index'
+ map.connect ':controller/:action/:id'
+ 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 "/action_pack_assertions/foo"
+ end
+ end
+
# test the flash-based assertions with something is in the flash
def test_flash_assertions_full
process :flash_me
View
2 actionpack/test/controller/test_test.rb
@@ -86,7 +86,7 @@ def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
ActionController::Routing::Routes.reload
- ActionController::Routing.use_controllers! %w(content admin/user)
+ ActionController::Routing.use_controllers! %w(content admin/user test_test/test)
end
def teardown

0 comments on commit 3054a74

Please sign in to comment.
Something went wrong with that request. Please try again.