Skip to content

Commit

Permalink
Fix for #161 When using Rails 2.3 it uses Rack::Utils to parse params
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Ford authored and lukemelia committed Mar 1, 2009
1 parent 00433ba commit 740bb29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -2,6 +2,7 @@

* Minor enhancements

* When using Rails 2.3, use Rack::Utils to parse params (Matthew Ford)
* Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
* Add application_framework config for Selenium mode to determine how to
start and stop the app server (Corey Donohoe)
Expand Down
13 changes: 8 additions & 5 deletions lib/webrat/core/elements/field.rb
Expand Up @@ -80,7 +80,7 @@ def to_param

case Webrat.configuration.mode
when :rails
rails_request_parser.parse_query_parameters("#{name}=#{escaped_value}")
parse_rails_request_params("#{name}=#{escaped_value}")
when :merb
::Merb::Parse.query("#{name}=#{escaped_value}")
else
Expand All @@ -98,12 +98,15 @@ def unset

protected

def rails_request_parser
def parse_rails_request_params(params)
if defined?(ActionController::AbstractRequest)
ActionController::AbstractRequest
else
ActionController::AbstractRequest.parse_query_parameters(params)
elsif defined?(ActionController::UrlEncodedPairParser)
# For Rails > 2.2
ActionController::UrlEncodedPairParser
ActionController::UrlEncodedPairParser.parse_query_parameters(params)
else
# For Rails > 2.3
Rack::Utils.parse_nested_query(params)
end
end

Expand Down

0 comments on commit 740bb29

Please sign in to comment.