From 4ac4e2fbc451df15b49f81e639dfb97c18e8e89a Mon Sep 17 00:00:00 2001 From: xibbar Date: Wed, 17 Sep 2008 04:49:28 +0000 Subject: [PATCH] * 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 --- ChangeLog | 7 +++++++ lib/cgi/html.rb | 12 ++++++------ test/cgi/test_cgi_tag_helper.rb | 8 ++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8a1973bcf..d1212ff801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Sep 17 13:42:59 2008 Takeyuki Fujioka + + * 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 * numeric.c: provides predicate real? instead of scalar?. diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb index abc83cd23a..23d5ae9bea 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 3ff2f54d42..38533a11e8 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('foo',cgi.th{'foo'}) assert_equal('',cgi.td) assert_equal('foo',cgi.td{'foo'}) + str=cgi.checkbox_group("foo",["aa","bb"],["cc","dd"]) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) + str=cgi.radio_group("foo",["aa","bb"],["cc","dd"]) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) end =begin