Merge branch 'master' into sr_sinatra
This commit is contained in:
commit
5dc24c613e
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
* Minor enhancements
|
* Minor enhancements
|
||||||
|
|
||||||
|
* When faced with a label with no for attribute, that contains a hidden field
|
||||||
|
and another field, as can be the case in Rails 2.3's checkbox view,
|
||||||
|
webrat now locates the non-hidden field. (Luke Melia)
|
||||||
|
* When using Rails 2.3, use Rack::Utils to parse params (Matthew Ford)
|
||||||
* Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
|
* Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
|
||||||
* Add application_framework config for Selenium mode to determine how to
|
* Add application_framework config for Selenium mode to determine how to
|
||||||
start and stop the app server (Corey Donohoe)
|
start and stop the app server (Corey Donohoe)
|
||||||
|
@ -15,6 +15,10 @@ module Webrat
|
|||||||
def self.xpath_search
|
def self.xpath_search
|
||||||
[".//button", ".//input", ".//textarea", ".//select"]
|
[".//button", ".//input", ".//textarea", ".//select"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.xpath_search_excluding_hidden
|
||||||
|
[".//button", ".//input[ @type != 'hidden']", ".//textarea", ".//select"]
|
||||||
|
end
|
||||||
|
|
||||||
def self.field_classes
|
def self.field_classes
|
||||||
@field_classes || []
|
@field_classes || []
|
||||||
@ -80,7 +84,7 @@ module Webrat
|
|||||||
|
|
||||||
case Webrat.configuration.mode
|
case Webrat.configuration.mode
|
||||||
when :rails
|
when :rails
|
||||||
rails_request_parser.parse_query_parameters("#{name}=#{escaped_value}")
|
parse_rails_request_params("#{name}=#{escaped_value}")
|
||||||
when :merb
|
when :merb
|
||||||
::Merb::Parse.query("#{name}=#{escaped_value}")
|
::Merb::Parse.query("#{name}=#{escaped_value}")
|
||||||
else
|
else
|
||||||
@ -98,12 +102,15 @@ module Webrat
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def rails_request_parser
|
def parse_rails_request_params(params)
|
||||||
if defined?(ActionController::AbstractRequest)
|
if defined?(ActionController::AbstractRequest)
|
||||||
ActionController::AbstractRequest
|
ActionController::AbstractRequest.parse_query_parameters(params)
|
||||||
else
|
elsif defined?(ActionController::UrlEncodedPairParser)
|
||||||
# For Rails > 2.2
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Webrat
|
|||||||
|
|
||||||
def field_element
|
def field_element
|
||||||
if for_id.blank?
|
if for_id.blank?
|
||||||
Webrat::XML.xpath_at(@element, *Field.xpath_search)
|
Webrat::XML.xpath_at(@element, *Field.xpath_search_excluding_hidden)
|
||||||
else
|
else
|
||||||
Webrat::XML.css_search(@session.current_dom, "#" + for_id).first
|
Webrat::XML.css_search(@session.current_dom, "#" + for_id).first
|
||||||
end
|
end
|
||||||
|
@ -169,4 +169,23 @@ describe "uncheck" do
|
|||||||
check 'Option 2'
|
check 'Option 2'
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should uncheck rails style checkboxes nested inside a label" do
|
||||||
|
with_html <<-HTML
|
||||||
|
<html>
|
||||||
|
<form method="get" action="/login">
|
||||||
|
<label>
|
||||||
|
TOS
|
||||||
|
<input name="user[tos]" type="hidden" value="0" />
|
||||||
|
<input id="user_tos" name="user[tos]" type="checkbox" value="1" checked="checked" />
|
||||||
|
</label>
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
</html>
|
||||||
|
HTML
|
||||||
|
webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
||||||
|
uncheck "TOS"
|
||||||
|
click_button
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user