Created
June 5, 2011 07:35
-
-
Save tanzeeb/1008743 to your computer and use it in GitHub Desktop.
Rubinius: fix failing CGI specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8bce2d38208b255cdfe9b51d029d772a97104cee Mon Sep 17 00:00:00 2001 | |
From: Tanzeeb Khalili <[email protected]> | |
Date: Sun, 5 Jun 2011 16:37:30 -0400 | |
Subject: [PATCH 2/6] fixed failing specs in CGI::HtmlExtension#radio_group | |
--- | |
lib/cgi.rb | 5 ++++- | |
.../library/cgi/htmlextension/radio_group_spec.rb | 1 - | |
2 files changed, 4 insertions(+), 2 deletions(-) | |
diff --git a/lib/cgi.rb b/lib/cgi.rb | |
index ac333a0..b6d3148 100644 | |
--- a/lib/cgi.rb | |
+++ b/lib/cgi.rb | |
@@ -979,7 +979,7 @@ class CGI | |
def read_multipart(boundary, content_length) | |
params = Hash.new([]) | |
boundary = "--" + boundary | |
- quoted_boundary = Regexp.quote(boundary, "n") | |
+ quoted_boundary = Regexp.quote(boundary) | |
buf = "" | |
bufsize = 10 * 1024 | |
boundary_end="" | |
@@ -1943,6 +1943,9 @@ class CGI | |
if value[value.size - 1] == true | |
radio_button(name, value[0], true) + | |
value[value.size - 2] | |
+ elsif value[value.size - 1] == false | |
+ radio_button(name, value[0]) + | |
+ value[value.size - 2] | |
else | |
radio_button(name, value[0]) + | |
value[value.size - 1] | |
diff --git a/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb b/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb | |
index d5b5639..cb32ea1 100644 | |
--- a/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb | |
+++ b/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb | |
@@ -29,7 +29,6 @@ describe "CGI::HtmlExtension#radio_group" do | |
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", :not_closed => true) | |
end | |
- # TODO: CGI does not like passing false instead of true. | |
ruby_bug "http://redmine.ruby-lang.org/issues/show/444", "1.8.7" do | |
it "allows passing a value as an Array containing the value, a label and the checked state" do | |
output = CGISpecs.split(@html.radio_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true])) | |
-- | |
1.7.3.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8676da48275ba7cd9b4ebbb5b9373aad5b6ab38f Mon Sep 17 00:00:00 2001 | |
From: Tanzeeb Khalili <[email protected]> | |
Date: Sun, 5 Jun 2011 17:00:54 -0400 | |
Subject: [PATCH 3/6] fixed failing CGI::HtmlExtension#img specs | |
--- | |
lib/cgi.rb | 9 ++++++--- | |
1 files changed, 6 insertions(+), 3 deletions(-) | |
diff --git a/lib/cgi.rb b/lib/cgi.rb | |
index b6d3148..107a96d 100644 | |
--- a/lib/cgi.rb | |
+++ b/lib/cgi.rb | |
@@ -1722,12 +1722,15 @@ class CGI | |
# # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50"> | |
def img(src = "", alt = "", width = nil, height = nil) | |
attributes = if src.kind_of?(String) | |
- { "SRC" => src, "ALT" => alt } | |
+ { | |
+ "SRC" => src, "ALT" => alt, | |
+ "WIDTH" => width, "HEIGHT" => height | |
+ } | |
else | |
src | |
end | |
- attributes["WIDTH"] = width.to_s if width | |
- attributes["HEIGHT"] = height.to_s if height | |
+ attributes["WIDTH"] = attributes["WIDTH"].to_s if attributes["WIDTH"] | |
+ attributes["HEIGHT"] = attributes["HEIGHT"].to_s if attributes["HEIGHT"] | |
super(attributes) | |
end | |
-- | |
1.7.3.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2baa4b77ab0373f46f10b33123026d8191fad058 Mon Sep 17 00:00:00 2001 | |
From: Tanzeeb Khalili <[email protected]> | |
Date: Sun, 5 Jun 2011 17:09:44 -0400 | |
Subject: [PATCH 4/6] fixed failing CGI::HtmlExtension#checkbox_group specs | |
--- | |
lib/cgi.rb | 3 +++ | |
1 files changed, 3 insertions(+), 0 deletions(-) | |
diff --git a/lib/cgi.rb b/lib/cgi.rb | |
index 107a96d..b0be0b5 100644 | |
--- a/lib/cgi.rb | |
+++ b/lib/cgi.rb | |
@@ -1488,6 +1488,9 @@ class CGI | |
if value[value.size - 1] == true | |
checkbox(name, value[0], true) + | |
value[value.size - 2] | |
+ elsif value[value.size - 1] == false | |
+ checkbox(name, value[0]) + | |
+ value[value.size - 2] | |
else | |
checkbox(name, value[0]) + | |
value[value.size - 1] | |
-- | |
1.7.3.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From d9561ac6d3eea8f6fba5ad2bf5fa000de5b561b8 Mon Sep 17 00:00:00 2001 | |
From: Tanzeeb Khalili <[email protected]> | |
Date: Sun, 5 Jun 2011 17:16:14 -0400 | |
Subject: [PATCH 5/6] fixed failing CGI::HtmlExtension#file_field specs | |
--- | |
lib/cgi.rb | 14 ++++++++++++-- | |
1 files changed, 12 insertions(+), 2 deletions(-) | |
diff --git a/lib/cgi.rb b/lib/cgi.rb | |
index b0be0b5..6b8e0ca 100644 | |
--- a/lib/cgi.rb | |
+++ b/lib/cgi.rb | |
@@ -1522,14 +1522,24 @@ class CGI | |
# file_field("NAME" => "name", "SIZE" => 40) | |
# # <INPUT TYPE="file" NAME="name" SIZE="40"> | |
def file_field(name = "", size = 20, maxlength = nil) | |
+ # attributes = if name.kind_of?(String) | |
+ # { "TYPE" => "file", "NAME" => name, | |
+ # "SIZE" => size.to_s } | |
+ # else | |
+ # name["TYPE"] = "file" | |
+ # name | |
+ # end | |
+ # attributes["MAXLENGTH"] = maxlength.to_s if maxlength | |
+ # input(attributes) | |
attributes = if name.kind_of?(String) | |
{ "TYPE" => "file", "NAME" => name, | |
- "SIZE" => size.to_s } | |
+ "SIZE" => size, "MAXLENGTH" => maxlength } | |
else | |
name["TYPE"] = "file" | |
name | |
end | |
- attributes["MAXLENGTH"] = maxlength.to_s if maxlength | |
+ attributes["SIZE"] = attributes["SIZE"].to_s if attributes["SIZE"] | |
+ attributes["MAXLENGTH"] = attributes["MAXLENGTH"].to_s if attributes["MAXLENGTH"] | |
input(attributes) | |
end | |
-- | |
1.7.3.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From db5a74eea9d4bfe6364b1e13ac29be4bd3f60a16 Mon Sep 17 00:00:00 2001 | |
From: Tanzeeb Khalili <[email protected]> | |
Date: Sun, 5 Jun 2011 17:21:42 -0400 | |
Subject: [PATCH 6/6] cleanup previous patch | |
--- | |
lib/cgi.rb | 9 --------- | |
1 files changed, 0 insertions(+), 9 deletions(-) | |
diff --git a/lib/cgi.rb b/lib/cgi.rb | |
index 6b8e0ca..d23fae8 100644 | |
--- a/lib/cgi.rb | |
+++ b/lib/cgi.rb | |
@@ -1522,15 +1522,6 @@ class CGI | |
# file_field("NAME" => "name", "SIZE" => 40) | |
# # <INPUT TYPE="file" NAME="name" SIZE="40"> | |
def file_field(name = "", size = 20, maxlength = nil) | |
- # attributes = if name.kind_of?(String) | |
- # { "TYPE" => "file", "NAME" => name, | |
- # "SIZE" => size.to_s } | |
- # else | |
- # name["TYPE"] = "file" | |
- # name | |
- # end | |
- # attributes["MAXLENGTH"] = maxlength.to_s if maxlength | |
- # input(attributes) | |
attributes = if name.kind_of?(String) | |
{ "TYPE" => "file", "NAME" => name, | |
"SIZE" => size, "MAXLENGTH" => maxlength } | |
-- | |
1.7.3.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment