actionpack 0.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (100) hide show
  1. data/CHANGELOG +604 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +418 -0
  4. data/RUNNING_UNIT_TESTS +14 -0
  5. data/examples/.htaccess +24 -0
  6. data/examples/address_book/index.rhtml +33 -0
  7. data/examples/address_book/layout.rhtml +8 -0
  8. data/examples/address_book_controller.cgi +9 -0
  9. data/examples/address_book_controller.fcgi +6 -0
  10. data/examples/address_book_controller.rb +52 -0
  11. data/examples/address_book_controller.rbx +4 -0
  12. data/examples/benchmark.rb +52 -0
  13. data/examples/benchmark_with_ar.fcgi +89 -0
  14. data/examples/blog_controller.cgi +53 -0
  15. data/examples/debate/index.rhtml +14 -0
  16. data/examples/debate/new_topic.rhtml +22 -0
  17. data/examples/debate/topic.rhtml +32 -0
  18. data/examples/debate_controller.cgi +57 -0
  19. data/install.rb +93 -0
  20. data/lib/action_controller.rb +47 -0
  21. data/lib/action_controller/assertions/action_pack_assertions.rb +166 -0
  22. data/lib/action_controller/assertions/active_record_assertions.rb +65 -0
  23. data/lib/action_controller/base.rb +626 -0
  24. data/lib/action_controller/benchmarking.rb +49 -0
  25. data/lib/action_controller/cgi_ext/cgi_ext.rb +43 -0
  26. data/lib/action_controller/cgi_ext/cgi_methods.rb +91 -0
  27. data/lib/action_controller/cgi_process.rb +123 -0
  28. data/lib/action_controller/filters.rb +279 -0
  29. data/lib/action_controller/flash.rb +65 -0
  30. data/lib/action_controller/layout.rb +143 -0
  31. data/lib/action_controller/request.rb +92 -0
  32. data/lib/action_controller/rescue.rb +94 -0
  33. data/lib/action_controller/response.rb +15 -0
  34. data/lib/action_controller/scaffolding.rb +183 -0
  35. data/lib/action_controller/session/active_record_store.rb +72 -0
  36. data/lib/action_controller/session/drb_server.rb +9 -0
  37. data/lib/action_controller/session/drb_store.rb +31 -0
  38. data/lib/action_controller/support/class_attribute_accessors.rb +57 -0
  39. data/lib/action_controller/support/class_inheritable_attributes.rb +37 -0
  40. data/lib/action_controller/support/clean_logger.rb +10 -0
  41. data/lib/action_controller/support/cookie_performance_fix.rb +121 -0
  42. data/lib/action_controller/support/inflector.rb +70 -0
  43. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +28 -0
  44. data/lib/action_controller/templates/rescues/diagnostics.rhtml +22 -0
  45. data/lib/action_controller/templates/rescues/layout.rhtml +29 -0
  46. data/lib/action_controller/templates/rescues/missing_template.rhtml +2 -0
  47. data/lib/action_controller/templates/rescues/template_error.rhtml +26 -0
  48. data/lib/action_controller/templates/rescues/unknown_action.rhtml +2 -0
  49. data/lib/action_controller/templates/scaffolds/edit.rhtml +6 -0
  50. data/lib/action_controller/templates/scaffolds/layout.rhtml +29 -0
  51. data/lib/action_controller/templates/scaffolds/list.rhtml +24 -0
  52. data/lib/action_controller/templates/scaffolds/new.rhtml +5 -0
  53. data/lib/action_controller/templates/scaffolds/show.rhtml +9 -0
  54. data/lib/action_controller/test_process.rb +194 -0
  55. data/lib/action_controller/url_rewriter.rb +153 -0
  56. data/lib/action_view.rb +40 -0
  57. data/lib/action_view/base.rb +253 -0
  58. data/lib/action_view/helpers/active_record_helper.rb +171 -0
  59. data/lib/action_view/helpers/date_helper.rb +223 -0
  60. data/lib/action_view/helpers/debug_helper.rb +17 -0
  61. data/lib/action_view/helpers/form_helper.rb +176 -0
  62. data/lib/action_view/helpers/form_options_helper.rb +169 -0
  63. data/lib/action_view/helpers/tag_helper.rb +59 -0
  64. data/lib/action_view/helpers/text_helper.rb +129 -0
  65. data/lib/action_view/helpers/url_helper.rb +72 -0
  66. data/lib/action_view/partials.rb +61 -0
  67. data/lib/action_view/template_error.rb +84 -0
  68. data/lib/action_view/vendor/builder.rb +13 -0
  69. data/lib/action_view/vendor/builder/blankslate.rb +21 -0
  70. data/lib/action_view/vendor/builder/xmlbase.rb +143 -0
  71. data/lib/action_view/vendor/builder/xmlevents.rb +63 -0
  72. data/lib/action_view/vendor/builder/xmlmarkup.rb +288 -0
  73. data/rakefile +105 -0
  74. data/test/abstract_unit.rb +9 -0
  75. data/test/controller/action_pack_assertions_test.rb +295 -0
  76. data/test/controller/active_record_assertions_test.rb +118 -0
  77. data/test/controller/cgi_test.rb +142 -0
  78. data/test/controller/cookie_test.rb +38 -0
  79. data/test/controller/filters_test.rb +159 -0
  80. data/test/controller/flash_test.rb +69 -0
  81. data/test/controller/layout_test.rb +49 -0
  82. data/test/controller/redirect_test.rb +44 -0
  83. data/test/controller/render_test.rb +169 -0
  84. data/test/controller/url_test.rb +318 -0
  85. data/test/fixtures/layouts/builder.rxml +3 -0
  86. data/test/fixtures/layouts/standard.rhtml +1 -0
  87. data/test/fixtures/test/_customer.rhtml +1 -0
  88. data/test/fixtures/test/greeting.rhtml +1 -0
  89. data/test/fixtures/test/hello.rxml +4 -0
  90. data/test/fixtures/test/hello_world.rhtml +1 -0
  91. data/test/fixtures/test/hello_xml_world.rxml +11 -0
  92. data/test/fixtures/test/list.rhtml +1 -0
  93. data/test/template/active_record_helper_test.rb +76 -0
  94. data/test/template/date_helper_test.rb +103 -0
  95. data/test/template/form_helper_test.rb +115 -0
  96. data/test/template/form_options_helper_test.rb +174 -0
  97. data/test/template/tag_helper_test.rb +18 -0
  98. data/test/template/text_helper_test.rb +62 -0
  99. data/test/template/url_helper_test.rb +35 -0
  100. metadata +154 -0
@@ -0,0 +1,9 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'test/unit'
4
+ require 'action_controller'
5
+
6
+ require 'action_controller/test_process'
7
+
8
+ ActionController::Base.logger = nil
9
+ ActionController::Base.ignore_missing_templates = true
@@ -0,0 +1,295 @@
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
+
3
+ # a controller class to facilitate the tests
4
+ class ActionPackAssertionsController < ActionController::Base
5
+
6
+ # this does absolutely nothing
7
+ def nothing() render_text ""; end
8
+
9
+ # a standard template
10
+ def hello_world() render "test/hello_world"; end
11
+
12
+ # a standard template
13
+ def hello_xml_world() render "test/hello_xml_world"; end
14
+
15
+ # a redirect to an internal location
16
+ def redirect_internal() redirect_to "nothing"; end
17
+
18
+ # a redirect to an external location
19
+ def redirect_external() redirect_to_url "http://www.rubyonrails.org"; end
20
+
21
+ # a 404
22
+ def response404() render_text "", "404 AWOL"; end
23
+
24
+ # a 500
25
+ def response500() render_text "", "500 Sorry"; end
26
+
27
+ # a fictional 599
28
+ def response599() render_text "", "599 Whoah!"; end
29
+
30
+ # putting stuff in the flash
31
+ def flash_me
32
+ flash['hello'] = 'my name is inigo montoya...'
33
+ render_text "Inconceivable!"
34
+ end
35
+
36
+ # we have a flash, but nothing is in it
37
+ def flash_me_naked
38
+ flash.clear
39
+ render_text "wow!"
40
+ end
41
+
42
+ # assign some template instance variables
43
+ def assign_this
44
+ @howdy = "ho"
45
+ render_text "Mr. Henke"
46
+ end
47
+
48
+ def render_based_on_parameters
49
+ render_text "Mr. #{@params["name"]}"
50
+ end
51
+
52
+ # puts something in the session
53
+ def session_stuffing
54
+ session['xmas'] = 'turkey'
55
+ render_text "ho ho ho"
56
+ end
57
+
58
+ # 911
59
+ def rescue_action(e) raise; end
60
+
61
+ end
62
+
63
+ # ---------------------------------------------------------------------------
64
+
65
+
66
+ # tell the controller where to find its templates but start from parent
67
+ # directory of test_request_response to simulate the behaviour of a
68
+ # production environment
69
+ ActionPackAssertionsController.template_root = File.dirname(__FILE__) + "/../fixtures/"
70
+
71
+
72
+ # a test case to exercise the new capabilities TestRequest & TestResponse
73
+ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
74
+ # let's get this party started
75
+ def setup
76
+ @controller = ActionPackAssertionsController.new
77
+ @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
78
+ end
79
+
80
+ # -- assertion-based testing ------------------------------------------------
81
+
82
+ # test the session assertion to make sure something is there.
83
+ def test_assert_session_has
84
+ process :session_stuffing
85
+ assert_session_has 'xmas'
86
+ assert_session_has_no 'halloween'
87
+ end
88
+
89
+ # test the assertion of goodies in the template
90
+ def test_assert_template_has
91
+ process :assign_this
92
+ assert_template_has 'howdy'
93
+ end
94
+
95
+ # test the assertion for goodies that shouldn't exist in the template
96
+ def test_assert_template_has_no
97
+ process :nothing
98
+ assert_template_has_no 'maple syrup'
99
+ assert_template_has_no 'howdy'
100
+ end
101
+
102
+ # test the redirection assertions
103
+ def test_assert_redirect
104
+ process :redirect_internal
105
+ assert_redirect
106
+ end
107
+
108
+ # test the redirect url string
109
+ def test_assert_redirect_url
110
+ process :redirect_external
111
+ assert_redirect_url 'http://www.rubyonrails.org'
112
+ end
113
+
114
+ # test the redirection pattern matching on a string
115
+ def test_assert_redirect_url_match_string
116
+ process :redirect_external
117
+ assert_redirect_url_match 'rails.org'
118
+ end
119
+
120
+ # test the redirection pattern matching on a pattern
121
+ def test_assert_redirect_url_match_pattern
122
+ process :redirect_external
123
+ assert_redirect_url_match /ruby/
124
+ end
125
+
126
+ # test the flash-based assertions with something is in the flash
127
+ def test_flash_assertions_full
128
+ process :flash_me
129
+ assert @response.has_flash_with_contents?
130
+ assert_flash_exists
131
+ assert ActionController::TestResponse.assertion_target.has_flash_with_contents?
132
+ assert_flash_not_empty
133
+ assert_flash_has 'hello'
134
+ assert_flash_has_no 'stds'
135
+ end
136
+
137
+ # test the flash-based assertions with no flash at all
138
+ def test_flash_assertions_negative
139
+ process :nothing
140
+ assert_flash_not_exists
141
+ assert_flash_empty
142
+ assert_flash_has_no 'hello'
143
+ assert_flash_has_no 'qwerty'
144
+ end
145
+
146
+ # test the assert_rendered_file
147
+ def test_assert_rendered_file
148
+ process :hello_world
149
+ assert_rendered_file 'test_request_response/hello_world'
150
+ assert_rendered_file 'hello_world'
151
+ assert_rendered_file
152
+ end
153
+
154
+ # test the assert_success assertion
155
+ def test_assert_success
156
+ process :nothing
157
+ assert_success
158
+ end
159
+
160
+ # -- standard request/reponse object testing --------------------------------
161
+
162
+ # ensure our session is working properly
163
+ def test_session_objects
164
+ process :session_stuffing
165
+ assert @response.has_session_object?('xmas')
166
+ assert !@response.has_session_object?('easter')
167
+ end
168
+
169
+ # make sure that the template objects exist
170
+ def test_template_objects_alive
171
+ process :assign_this
172
+ assert !@response.has_template_object?('hi')
173
+ assert @response.has_template_object?('howdy')
174
+ end
175
+
176
+ # make sure we don't have template objects when we shouldn't
177
+ def test_template_object_missing
178
+ process :nothing
179
+ assert_nil @response.template_objects['howdy']
180
+ end
181
+
182
+ # check the empty flashing
183
+ def test_flash_me_naked
184
+ process :flash_me_naked
185
+ assert @response.has_flash?
186
+ assert !@response.has_flash_with_contents?
187
+ end
188
+
189
+ # check if we have flash objects
190
+ def test_flash_haves
191
+ process :flash_me
192
+ assert @response.has_flash?
193
+ assert @response.has_flash_with_contents?
194
+ assert @response.has_flash_object?('hello')
195
+ end
196
+
197
+ # ensure we don't have flash objects
198
+ def test_flash_have_nots
199
+ process :nothing
200
+ assert !@response.has_flash?
201
+ assert !@response.has_flash_with_contents?
202
+ assert_nil @response.flash['hello']
203
+ end
204
+
205
+
206
+ # check if we were rendered by a file-based template?
207
+ def test_rendered_action
208
+ process :nothing
209
+ assert !@response.rendered_with_file?
210
+
211
+ process :hello_world
212
+ assert @response.rendered_with_file?
213
+ assert 'hello_world', @response.rendered_file
214
+ end
215
+
216
+ # check the redirection location
217
+ def test_redirection_location
218
+ process :redirect_internal
219
+ assert_equal 'nothing', @response.redirect_url
220
+
221
+ process :redirect_external
222
+ assert_equal 'http://www.rubyonrails.org', @response.redirect_url
223
+
224
+ process :nothing
225
+ assert_nil @response.redirect_url
226
+ end
227
+
228
+
229
+ # check server errors
230
+ def test_server_error_response_code
231
+ process :response500
232
+ assert @response.server_error?
233
+
234
+ process :response599
235
+ assert @response.server_error?
236
+
237
+ process :response404
238
+ assert !@response.server_error?
239
+ end
240
+
241
+ # check a 404 response code
242
+ def test_missing_response_code
243
+ process :response404
244
+ assert @response.missing?
245
+ end
246
+
247
+ # check to see if our redirection matches a pattern
248
+ def test_redirect_url_match
249
+ process :redirect_external
250
+ assert @response.redirect?
251
+ assert @response.redirect_url_match?("rubyonrails")
252
+ assert @response.redirect_url_match?(/rubyonrails/)
253
+ assert !@response.redirect_url_match?("phpoffrails")
254
+ assert !@response.redirect_url_match?(/perloffrails/)
255
+ end
256
+
257
+ # check for a redirection
258
+ def test_redirection
259
+ process :redirect_internal
260
+ assert @response.redirect?
261
+
262
+ process :redirect_external
263
+ assert @response.redirect?
264
+
265
+ process :nothing
266
+ assert !@response.redirect?
267
+ end
268
+
269
+ # check a successful response code
270
+ def test_successful_response_code
271
+ process :nothing
272
+ assert @response.success?
273
+ end
274
+
275
+ # a basic check to make sure we have a TestResponse object
276
+ def test_has_response
277
+ process :nothing
278
+ assert_kind_of ActionController::TestResponse, @response
279
+ end
280
+
281
+ def test_render_based_on_parameters
282
+ process :render_based_on_parameters, "name" => "David"
283
+ assert_equal "Mr. David", @response.body
284
+ end
285
+
286
+ def test_simple_one_element_xpath_match
287
+ process :hello_xml_world
288
+ assert_template_xpath_match('//title', "Hello World")
289
+ end
290
+
291
+ def test_array_of_elements_in_xpath_match
292
+ process :hello_xml_world
293
+ assert_template_xpath_match('//p', %w( abes monks wiseguys ))
294
+ end
295
+ end
@@ -0,0 +1,118 @@
1
+ path_to_ar = File.dirname(__FILE__) + '/../../../activerecord'
2
+
3
+ if Object.const_defined?("ActiveRecord") || File.exist?(path_to_ar)
4
+ # This test is very different than the others. It requires ActiveRecord to
5
+ # run. There's a bunch of stuff we are assuming here:
6
+ #
7
+ # 1. active_record exists as a sibling directory to actionpack
8
+ # 2. you've created the appropriate database to run the active_record unit tests
9
+ # 3. you set the appropriate database connection below
10
+
11
+ driver_to_use = 'native_sqlite'
12
+
13
+ $: << path_to_ar + '/lib/'
14
+ $: << path_to_ar + '/test/'
15
+ require 'active_record' unless Object.const_defined?("ActiveRecord")
16
+ require "connections/#{driver_to_use}/connection"
17
+ require 'fixtures/company'
18
+
19
+ # -----------------------------------------------------------------------------
20
+
21
+ # add some validation rules to trip up the assertions
22
+ class Company
23
+ def validate
24
+ errors.add_on_empty('name')
25
+ errors.add('rating', 'rating should not be 2') if rating == 2
26
+ errors.add_to_base('oh oh') if rating == 3
27
+ end
28
+ end
29
+
30
+ # -----------------------------------------------------------------------------
31
+
32
+ require File.dirname(__FILE__) + '/../abstract_unit'
33
+
34
+ # a controller class to handle the AR assertions
35
+ class ActiveRecordAssertionsController < ActionController::Base
36
+ # fail with 1 bad column
37
+ def nasty_columns_1
38
+ @company = Company.new
39
+ @company.name = "B"
40
+ @company.rating = 2
41
+ render_text "snicker...."
42
+ end
43
+
44
+ # fail with 2 bad column
45
+ def nasty_columns_2
46
+ @company = Company.new
47
+ @company.name = ""
48
+ @company.rating = 2
49
+ render_text "double snicker...."
50
+ end
51
+
52
+ # this will pass validation
53
+ def good_company
54
+ @company = Company.new
55
+ @company.name = "A"
56
+ @company.rating = 69
57
+ render_text "Goodness Gracious!"
58
+ end
59
+
60
+ # this will fail validation
61
+ def bad_company
62
+ @company = Company.new
63
+ render_text "Who's Bad?"
64
+ end
65
+
66
+ # the safety dance......
67
+ def rescue_action(e) raise; end
68
+ end
69
+
70
+ # -----------------------------------------------------------------------------
71
+
72
+ ActiveRecordAssertionsController.template_root = File.dirname(__FILE__) + "/../fixtures/"
73
+
74
+ # The test case to try the AR assertions
75
+ class ActiveRecordAssertionsControllerTest < Test::Unit::TestCase
76
+ # set it up
77
+ def setup
78
+ @request = ActionController::TestRequest.new
79
+ @response = ActionController::TestResponse.new
80
+ @controller = ActiveRecordAssertionsController.new
81
+ end
82
+
83
+ # test for 1 bad apple column
84
+ def test_some_invalid_columns
85
+ process :nasty_columns_1
86
+ assert_success
87
+ assert_invalid_record 'company'
88
+ assert_invalid_column_on_record 'company', 'rating'
89
+ assert_valid_column_on_record 'company', 'name'
90
+ assert_valid_column_on_record 'company', ['name','id']
91
+ end
92
+
93
+ # test for 2 bad apples columns
94
+ def test_all_invalid_columns
95
+ process :nasty_columns_2
96
+ assert_success
97
+ assert_invalid_record 'company'
98
+ assert_invalid_column_on_record 'company', 'rating'
99
+ assert_invalid_column_on_record 'company', 'name'
100
+ assert_invalid_column_on_record 'company', ['name','rating']
101
+ end
102
+
103
+ # ensure we have no problems with an ActiveRecord
104
+ def test_valid_record
105
+ process :good_company
106
+ assert_success
107
+ assert_valid_record 'company'
108
+ end
109
+
110
+ # ensure we have problems with an ActiveRecord
111
+ def test_invalid_record
112
+ process :bad_company
113
+ assert_success
114
+ assert_invalid_record 'company'
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,142 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
+
3
+ require 'test/unit'
4
+ require 'action_controller/cgi_ext/cgi_methods'
5
+ require 'stringio'
6
+
7
+ class MockUploadedFile < StringIO
8
+ def content_type
9
+ "img/jpeg"
10
+ end
11
+
12
+ def original_filename
13
+ "my_file.doc"
14
+ end
15
+ end
16
+
17
+ class CGITest < Test::Unit::TestCase
18
+ def setup
19
+ @query_string = "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1"
20
+ @query_string_with_nil = "action=create_customer&full_name="
21
+ @query_string_with_array = "action=create_customer&selected[]=1&selected[]=2&selected[]=3"
22
+ @query_string_with_amps = "action=create_customer&name=Don%27t+%26+Does"
23
+ @query_string_with_multiple_of_same_name =
24
+ "action=update_order&full_name=Lau%20Taarnskov&products=4&products=2&products=3"
25
+ end
26
+
27
+ def test_query_string
28
+ assert_equal(
29
+ { "action" => "create_customer", "full_name" => "David Heinemeier Hansson", "customerId" => "1"},
30
+ CGIMethods.parse_query_parameters(@query_string)
31
+ )
32
+ end
33
+
34
+ def test_query_string_with_nil
35
+ assert_equal(
36
+ { "action" => "create_customer", "full_name" => nil},
37
+ CGIMethods.parse_query_parameters(@query_string_with_nil)
38
+ )
39
+ end
40
+
41
+ def test_query_string_with_array
42
+ assert_equal(
43
+ { "action" => "create_customer", "selected" => ["1", "2", "3"]},
44
+ CGIMethods.parse_query_parameters(@query_string_with_array)
45
+ )
46
+ end
47
+
48
+ def test_query_string_with_amps
49
+ assert_equal(
50
+ { "action" => "create_customer", "name" => "Don't & Does"},
51
+ CGIMethods.parse_query_parameters(@query_string_with_amps)
52
+ )
53
+ end
54
+
55
+ def test_parse_params
56
+ input = {
57
+ "customers[boston][first][name]" => [ "David" ],
58
+ "customers[boston][first][url]" => [ "http://David" ],
59
+ "customers[boston][second][name]" => [ "Allan" ],
60
+ "customers[boston][second][url]" => [ "http://Allan" ],
61
+ "something_else" => [ "blah" ],
62
+ "something_nil" => [ nil ],
63
+ "something_empty" => [ "" ],
64
+ "products[first]" => [ "Apple Computer" ],
65
+ "products[second]" => [ "Pc" ]
66
+ }
67
+
68
+ expected_output = {
69
+ "customers" => {
70
+ "boston" => {
71
+ "first" => {
72
+ "name" => "David",
73
+ "url" => "http://David"
74
+ },
75
+ "second" => {
76
+ "name" => "Allan",
77
+ "url" => "http://Allan"
78
+ }
79
+ }
80
+ },
81
+ "something_else" => "blah",
82
+ "something_empty" => "",
83
+ "something_nil" => "",
84
+ "products" => {
85
+ "first" => "Apple Computer",
86
+ "second" => "Pc"
87
+ }
88
+ }
89
+
90
+ assert_equal expected_output, CGIMethods.parse_request_parameters(input)
91
+ end
92
+
93
+ def test_parse_params_from_multipart_upload
94
+ mock_file = MockUploadedFile.new
95
+
96
+ input = {
97
+ "something" => [ StringIO.new("") ],
98
+ "products[string]" => [ StringIO.new("Apple Computer") ],
99
+ "products[file]" => [ mock_file ]
100
+ }
101
+
102
+ expected_output = {
103
+ "something" => "",
104
+ "products" => {
105
+ "string" => "Apple Computer",
106
+ "file" => mock_file
107
+ }
108
+ }
109
+
110
+ assert_equal expected_output, CGIMethods.parse_request_parameters(input)
111
+ end
112
+
113
+ def test_parse_params_with_file
114
+ input = {
115
+ "customers[boston][first][name]" => [ "David" ],
116
+ "something_else" => [ "blah" ],
117
+ "logo" => [ File.new(File.dirname(__FILE__) + "/cgi_test.rb").path ]
118
+ }
119
+
120
+ expected_output = {
121
+ "customers" => {
122
+ "boston" => {
123
+ "first" => {
124
+ "name" => "David"
125
+ }
126
+ }
127
+ },
128
+ "something_else" => "blah",
129
+ "logo" => File.new(File.dirname(__FILE__) + "/cgi_test.rb").path,
130
+ }
131
+
132
+ assert_equal expected_output, CGIMethods.parse_request_parameters(input)
133
+ end
134
+
135
+ def test_parse_params_with_array
136
+ input = { "selected[]" => [ "1", "2", "3" ] }
137
+
138
+ expected_output = { "selected" => [ "1", "2", "3" ] }
139
+
140
+ assert_equal expected_output, CGIMethods.parse_request_parameters(input)
141
+ end
142
+ end