Skip to content
Browse files

More tweaks to make sure assert_redirected_to works with symbols

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4649 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 0cfde5f commit 49f44daf174ab18e00d16e9df1b153b660483261 @jamis jamis committed
Showing with 8 additions and 2 deletions.
  1. +8 −2 actionpack/lib/action_controller/assertions.rb
View
10 actionpack/lib/action_controller/assertions.rb
@@ -81,8 +81,9 @@ def assert_redirected_to(options = {}, message=nil)
original = { :expected => options, :actual => @response.redirected_to.is_a?(Symbol) ? @response.redirected_to : @response.redirected_to.dup }
original.each do |key, value|
if value.is_a?(Symbol)
- value = @controller.respond_to?(value, true) ? @controller.send(value) : @controller.send("hash_for_#{option}")
+ value = @controller.respond_to?(value, true) ? @controller.send(value) : @controller.send("hash_for_#{value}_url")
end
+
unless value.is_a?(Hash)
request = case value
when NilClass then nil
@@ -91,8 +92,13 @@ def assert_redirected_to(options = {}, message=nil)
end
value = request.path_parameters if request
end
-
+
if value.is_a?(Hash) # stringify 2 levels of hash keys
+ if name = value.delete(:use_route)
+ route = ActionController::Routing::Routes.named_routes[name]
+ value.update(route.parameter_shell)
+ end
+
value.stringify_keys!
value.values.select { |v| v.is_a?(Hash) }.collect { |v| v.stringify_keys! }
if key == :expected && value['controller'] == @controller.controller_name && original[:actual].is_a?(Hash)

0 comments on commit 49f44da

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