Skip to content
Browse files

Fix url_for, redirect_to, etc. with :controller => :symbol instead of…

… 'string'. Closes #8562, #9525.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7776 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent c90d31e commit d9f3c435f907b8097669a7f2c923f731837fb045 @jeremy jeremy committed Oct 7, 2007
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix url_for, redirect_to, etc. with :controller => :symbol instead of 'string'. #8562, #9525 [Justin Lynn, Tarmo Tänav, shoe]
+
* Use #require_library_or_gem to load the memcache library for the MemCache session and fragment cache stores. Closes #8662. [Rick]
* Move ActionController::Routing.optimise_named_routes to ActionController::Base.optimise_named_routes. Now you can set it in the config. [Rick]
View
3 actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -69,6 +69,7 @@ def assert_redirected_to(options = {}, message=nil)
end
if value.respond_to?(:[]) && value['controller']
+ 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)
@@ -138,4 +139,4 @@ def parameterize(value)
end
end
end
-end
+end
View
3 actionpack/lib/action_controller/routing.rb
@@ -1325,6 +1325,9 @@ def generate(options, recall = {}, method=:generate)
options = options_as_params(options)
expire_on = build_expiry(options, recall)
+ if options[:controller]
+ options[:controller] = options[:controller].to_s
+ end
# if the controller has changed, make sure it changes relative to the
# current controller module, if any. In other words, if we're currently
# on admin/get, and the new controller is 'set', the new controller
View
13 actionpack/test/controller/action_pack_assertions_test.rb
@@ -19,6 +19,8 @@ def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params =>
def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end
+ def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere, :action => :flash_me; end
+
def redirect_to_path() redirect_to '/some/path' end
def redirect_to_named_route() redirect_to route_one_url end
@@ -429,6 +431,17 @@ def test_redirected_to_url_full_url
assert_redirected_to 'http://test.host/some/path'
end
+ def test_assert_redirection_with_symbol
+ process :redirect_to_controller_with_symbol
+ assert_nothing_raised {
+ assert_redirected_to :controller => "elsewhere", :action => "flash_me"
+ }
+ process :redirect_to_controller_with_symbol
+ assert_nothing_raised {
+ assert_redirected_to :controller => :elsewhere, :action => :flash_me
+ }
+ end
+
def test_redirected_to_with_nested_controller
@controller = Admin::InnerModuleController.new
get :redirect_to_absolute_controller
View
4 actionpack/test/controller/url_rewriter_test.rb
@@ -234,6 +234,10 @@ def test_hash_recursive_and_array_parameters
assert_equal params[3], { 'query[person][position][]' => 'art director' }.to_query
end
+ def test_path_generation_for_symbol_parameter_keys
+ assert_generates("/image", :controller=> :image)
+ end
+
private
def extract_params(url)
url.split('?', 2).last.split('&')

0 comments on commit d9f3c43

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