test/nitro/adapter/tc_cgi.rb in nitro-0.22.0 vs test/nitro/adapter/tc_cgi.rb in nitro-0.23.0
- old
+ new
@@ -1,17 +1,24 @@
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
+require 'nano/object/assign_with'
+
require 'socket'
require 'ostruct'
require 'test/unit'
require 'nitro/cookie'
require 'nitro/adapter/cgi'
-class TC_AdaptersCgi < Test::Unit::TestCase # :nodoc: all
+class TestAdapterCgi < Test::Unit::TestCase # :nodoc: all
include Nitro
-
+
+ class User
+ attr_accessor :name
+ attr_accessor :password
+ end
+
def test_parse_query_parameters
qs = 'name=tml;id=12354'
params = CgiUtils.parse_query_string(qs)
assert_equal 2, params.size
assert_equal 'tml', params['name']
@@ -28,9 +35,32 @@
params = CgiUtils.parse_query_string(qs)
assert_equal 2, params.size
arr = params['arr']
assert_equal Array, arr.class
assert_equal 3, arr.size
+
+ qs = 'other=1;user.name=gmosx;user.password=hello'
+ params = CgiUtils.parse_query_string(qs)
+ assert_equal 2, params.size
+ u = params['user']
+ assert_equal Hash, u.class
+ assert_equal 'gmosx', u['name']
+ assert_equal 'hello', u['password']
+
+ user = User.new
+ user.assign_with(params['user'])
+ assert_equal 'gmosx', user.name
+ assert_equal 'hello', user.password
+
+ # Ruby/Scriptaculous compatibility.
+
+ qs = 'other=1;user[name]=gmosx;user[password]=hello'
+ params = CgiUtils.parse_query_string(qs)
+ assert_equal 2, params.size
+ u = params['user']
+ assert_equal Hash, u.class
+ assert_equal 'gmosx', u['name']
+ assert_equal 'hello', u['password']
end
def test_parse_cookies
context = OpenStruct.new
context.env = {}