Fixed bug where disabled fields would be submitted.

This commit is contained in:
nicholas a. evans 2008-09-22 22:19:20 -04:00
parent 7c46a6fed0
commit c5e3546cff
2 changed files with 21 additions and 1 deletions

View File

@ -47,10 +47,15 @@ module Webrat
end
def to_param
return nil if disabled?
value = @value.to_s.gsub('&', '%26')
param_parser.parse_query_parameters("#{name}=#{value}")
end
def disabled?
@element.attributes.has_key? "disabled"
end
def set(value)
@value = value
end

View File

@ -154,6 +154,21 @@ describe "clicks_button" do
@session.clicks_button
end
it "should not send disabled field values" do
@session.response_body = <<-EOS
<form method="get" action="/login">
<input disabled id="user_email" name="user[email]" value="test@example.com" type="text" />
<input disabled id="user_gender_male" name="user[gender]" type="radio" value="M" />
<label for="user_gender_male">Male</label>
<input disabled id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
<label for="user_gender_female">Female</label>
<input type="submit" />
</form>
EOS
@session.should_receive(:get).with("/login", {})
@session.clicks_button
end
it "should send default checked fields" do
@session.response_body = <<-EOS
<form method="get" action="/login">