Skip to content

Commit f70b74a

Browse files
committed
Backport fix to allow :controller=>:some_symbol [norbert]
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7838 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
1 parent 88f2284 commit f70b74a

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

actionpack/lib/action_controller/assertions/response_assertions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def assert_redirected_to(options = {}, message=nil)
6969
end
7070

7171
if value.respond_to?(:[]) && value['controller']
72+
value['controller'] = value['controller'].to_s
7273
if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
7374
new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
7475
value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path)

actionpack/lib/action_controller/routing.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,9 @@ def generate(options, recall = {}, method=:generate)
12541254
options = options_as_params(options)
12551255
expire_on = build_expiry(options, recall)
12561256

1257+
if options[:controller]
1258+
options[:controller] = options[:controller].to_s
1259+
end
12571260
# if the controller has changed, make sure it changes relative to the
12581261
# current controller module, if any. In other words, if we're currently
12591262
# on admin/get, and the new controller is 'set', the new controller

actionpack/test/controller/action_pack_assertions_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params =>
1919

2020
def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end
2121

22+
def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere, :action => :flash_me; end
23+
2224
def redirect_to_path() redirect_to '/some/path' end
2325

2426
def redirect_to_named_route() redirect_to route_one_url end
@@ -555,6 +557,17 @@ def test_redirected_to_url_full_url
555557
assert_redirected_to 'http://test.host/some/path'
556558
end
557559

560+
def test_assert_redirection_with_symbol
561+
process :redirect_to_controller_with_symbol
562+
assert_nothing_raised {
563+
assert_redirected_to :controller => "elsewhere", :action => "flash_me"
564+
}
565+
process :redirect_to_controller_with_symbol
566+
assert_nothing_raised {
567+
assert_redirected_to :controller => :elsewhere, :action => :flash_me
568+
}
569+
end
570+
558571
def test_redirected_to_with_nested_controller
559572
@controller = Admin::InnerModuleController.new
560573
get :redirect_to_absolute_controller

actionpack/test/controller/url_rewriter_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def test_hash_recursive_and_array_parameters
160160
assert_equal params[3], { 'query[person][position][]' => 'prof' }.to_query
161161
end
162162

163+
def test_path_generation_for_symbol_parameter_keys
164+
assert_generates("/image", :controller=> :image)
165+
end
166+
163167
private
164168
def extract_params(url)
165169
url.split('?', 2).last.split('&')

0 commit comments

Comments
 (0)