1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
xibbar 2008-09-17 04:49:28 +00:00
parent b27d5a7aa1
commit 4ac4e2fbc4
3 changed files with 21 additions and 6 deletions

View file

@ -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?.

View file

@ -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

View file

@ -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