From c5e3546cffc471898b1012176cc4b9cb6a53fec5 Mon Sep 17 00:00:00 2001 From: "nicholas a. evans" Date: Mon, 22 Sep 2008 22:19:20 -0400 Subject: [PATCH] Fixed bug where disabled fields would be submitted. --- lib/webrat/core/field.rb | 7 ++++++- spec/api/clicks_button_spec.rb | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/webrat/core/field.rb b/lib/webrat/core/field.rb index 21c878f..2d6bb1c 100644 --- a/lib/webrat/core/field.rb +++ b/lib/webrat/core/field.rb @@ -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 diff --git a/spec/api/clicks_button_spec.rb b/spec/api/clicks_button_spec.rb index 3978e4b..747013c 100644 --- a/spec/api/clicks_button_spec.rb +++ b/spec/api/clicks_button_spec.rb @@ -154,6 +154,21 @@ describe "clicks_button" do @session.clicks_button end + it "should not send disabled field values" do + @session.response_body = <<-EOS +
+ + + + + + +
+ EOS + @session.should_receive(:get).with("/login", {}) + @session.clicks_button + end + it "should send default checked fields" do @session.response_body = <<-EOS