From 030412bd3fe2f77c624b90498d7c1f2e16df9b92 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 17 Jan 2009 13:34:06 -0500 Subject: [PATCH] Minor refactoring to extract rails_request_parser --- lib/webrat/core/elements/field.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index 257c142..9c5073e 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -79,11 +79,7 @@ module Webrat case Webrat.configuration.mode when :rails - if defined?(ActionController::RequestParser) - ActionController::RequestParser.parse_query_parameters("#{name}=#{escaped_value}") - else - ActionController::AbstractRequest.parse_query_parameters("#{name}=#{escaped_value}") - end + rails_request_parser.parse_query_parameters("#{name}=#{escaped_value}") when :merb ::Merb::Parse.query("#{name}=#{escaped_value}") else @@ -101,6 +97,14 @@ module Webrat protected + def rails_request_parser + if defined?(ActionController::RequestParser) # For Rails > 2.2 + ActionController::RequestParser + else + ActionController::AbstractRequest + end + end + def form Form.load(@session, form_element) end