diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-28 12:43:13 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-28 12:43:13 -0700 |
commit | a46b03e728b6bc391c318d84f5bf6dfcc234b41d (patch) | |
tree | ffdb764035aa56bb79b3013be62452e9347e5ddd /actionpack/lib/action_controller | |
parent | 2fd7ea97ecfd40ee23e0f75ee0ed9a4febcbdb15 (diff) | |
parent | 3f0c71c8524856c32bc056bdb38136b3d18f2aaf (diff) | |
download | rails-a46b03e728b6bc391c318d84f5bf6dfcc234b41d.tar.gz rails-a46b03e728b6bc391c318d84f5bf6dfcc234b41d.tar.bz2 rails-a46b03e728b6bc391c318d84f5bf6dfcc234b41d.zip |
Merge pull request #1203 from dchelimsky/stringify-parameter-values-in-tests
Stringify param values in controller tests.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 2ca9bae073..bfb820fcdf 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -395,7 +395,26 @@ module ActionController end alias xhr :xml_http_request + def paramify_values(hash_or_array_or_value) + case hash_or_array_or_value + when Hash + hash_or_array_or_value.each do |key, value| + hash_or_array_or_value[key] = paramify_values(value) + end + when Array + hash_or_array_or_value.map {|i| paramify_values(i)} + when Rack::Test::UploadedFile + hash_or_array_or_value + else + hash_or_array_or_value.to_param + end + end + def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET') + # Ensure that numbers and symbols passed as params are converted to + # proper params, as is the case when engaging rack. + paramify_values(parameters) + # Sanity check for required instance variables so we can give an # understandable error message. %w(@routes @controller @request @response).each do |iv_name| |