summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-17 04:49:28 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-17 04:49:28 +0000
commit4ac4e2fbc451df15b49f81e639dfb97c18e8e89a (patch)
treef0bb0eb1cd75e7013c9327f4a8622d7ad98f6d06
parentb27d5a7aa1438c8fe381434e21d4b838e914e450 (diff)
* lib/cgi/html.rb (checkbox_group,radio_group): bug fix
use size instead of bytesize. * test/cgi/test_cgi_tag_helper.rb: test for checkbox_group,radio_group. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/cgi/html.rb12
-rwxr-xr-xtest/cgi/test_cgi_tag_helper.rb8
3 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f8a1973bcf6..d1212ff8018 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Sep 17 13:42:59 2008 Takeyuki Fujioka <xibbar@ruby-lang.org>
+
+ * lib/cgi/html.rb (checkbox_group,radio_group): bug fix
+ use size instead of bytesize.
+
+ * test/cgi/test_cgi_tag_helper.rb: test for checkbox_group,radio_group.
+
Wed Sep 17 06:58:31 2008 Tadayoshi Funaba <tadf@dotrb.org>
* numeric.c: provides predicate real? instead of scalar?.
diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb
index abc83cd23a1..23d5ae9beaf 100644
--- a/lib/cgi/html.rb
+++ b/lib/cgi/html.rb
@@ -248,12 +248,12 @@ class CGI
if value.kind_of?(String)
checkbox(name, value) + value
else
- if value[value.bytesize - 1] == true
+ if value[value.size - 1] == true
checkbox(name, value[0], true) +
- value[value.bytesize - 2]
+ value[value.size - 2]
else
checkbox(name, value[0]) +
- value[value.bytesize - 1]
+ value[value.size - 1]
end
end
}.join
@@ -703,12 +703,12 @@ class CGI
if value.kind_of?(String)
radio_button(name, value) + value
else
- if value[value.bytesize - 1] == true
+ if value[value.size - 1] == true
radio_button(name, value[0], true) +
- value[value.bytesize - 2]
+ value[value.size - 2]
else
radio_button(name, value[0]) +
- value[value.bytesize - 1]
+ value[value.size - 1]
end
end
}.join
diff --git a/test/cgi/test_cgi_tag_helper.rb b/test/cgi/test_cgi_tag_helper.rb
index 3ff2f54d420..38533a11e80 100755
--- a/test/cgi/test_cgi_tag_helper.rb
+++ b/test/cgi/test_cgi_tag_helper.rb
@@ -305,6 +305,14 @@ class CGITagHelperTest < Test::Unit::TestCase
assert_equal('<TH>foo</TH>',cgi.th{'foo'})
assert_equal('<TD>',cgi.td)
assert_equal('<TD>foo</TD>',cgi.td{'foo'})
+ str=cgi.checkbox_group("foo",["aa","bb"],["cc","dd"])
+ assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str)
+ assert_match(/^<INPUT .*TYPE="checkbox".*>bb<INPUT .*TYPE="checkbox".*>dd$/,str)
+ assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
+ str=cgi.radio_group("foo",["aa","bb"],["cc","dd"])
+ assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str)
+ assert_match(/^<INPUT .*TYPE="radio".*>bb<INPUT .*TYPE="radio".*>dd$/,str)
+ assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
end
=begin