actionpack 2.2.3 → 2.3.2

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 (264) hide show
  1. data/CHANGELOG +433 -375
  2. data/MIT-LICENSE +1 -1
  3. data/README +21 -75
  4. data/Rakefile +1 -1
  5. data/lib/action_controller.rb +80 -43
  6. data/lib/action_controller/assertions/model_assertions.rb +1 -0
  7. data/lib/action_controller/assertions/response_assertions.rb +43 -16
  8. data/lib/action_controller/assertions/routing_assertions.rb +1 -1
  9. data/lib/action_controller/assertions/selector_assertions.rb +17 -12
  10. data/lib/action_controller/assertions/tag_assertions.rb +1 -4
  11. data/lib/action_controller/base.rb +153 -82
  12. data/lib/action_controller/benchmarking.rb +9 -9
  13. data/lib/action_controller/caching.rb +9 -11
  14. data/lib/action_controller/caching/actions.rb +11 -18
  15. data/lib/action_controller/caching/fragments.rb +28 -20
  16. data/lib/action_controller/caching/pages.rb +13 -15
  17. data/lib/action_controller/caching/sweeping.rb +2 -2
  18. data/lib/action_controller/cgi_ext.rb +0 -1
  19. data/lib/action_controller/cgi_ext/cookie.rb +2 -0
  20. data/lib/action_controller/cgi_process.rb +54 -162
  21. data/lib/action_controller/cookies.rb +13 -25
  22. data/lib/action_controller/dispatcher.rb +43 -122
  23. data/lib/action_controller/failsafe.rb +52 -0
  24. data/lib/action_controller/flash.rb +38 -47
  25. data/lib/action_controller/helpers.rb +13 -9
  26. data/lib/action_controller/http_authentication.rb +203 -23
  27. data/lib/action_controller/integration.rb +126 -70
  28. data/lib/action_controller/layout.rb +36 -39
  29. data/lib/action_controller/middleware_stack.rb +119 -0
  30. data/lib/action_controller/middlewares.rb +13 -0
  31. data/lib/action_controller/mime_responds.rb +19 -4
  32. data/lib/action_controller/mime_type.rb +8 -0
  33. data/lib/action_controller/params_parser.rb +71 -0
  34. data/lib/action_controller/performance_test.rb +0 -1
  35. data/lib/action_controller/polymorphic_routes.rb +36 -30
  36. data/lib/action_controller/reloader.rb +14 -0
  37. data/lib/action_controller/request.rb +107 -499
  38. data/lib/action_controller/request_forgery_protection.rb +7 -39
  39. data/lib/action_controller/rescue.rb +55 -35
  40. data/lib/action_controller/resources.rb +34 -31
  41. data/lib/action_controller/response.rb +99 -57
  42. data/lib/action_controller/rewindable_input.rb +28 -0
  43. data/lib/action_controller/routing.rb +7 -7
  44. data/lib/action_controller/routing/builder.rb +4 -1
  45. data/lib/action_controller/routing/optimisations.rb +1 -1
  46. data/lib/action_controller/routing/recognition_optimisation.rb +1 -2
  47. data/lib/action_controller/routing/route.rb +15 -5
  48. data/lib/action_controller/routing/route_set.rb +82 -35
  49. data/lib/action_controller/routing/segments.rb +35 -0
  50. data/lib/action_controller/session/abstract_store.rb +181 -0
  51. data/lib/action_controller/session/cookie_store.rb +197 -175
  52. data/lib/action_controller/session/mem_cache_store.rb +36 -83
  53. data/lib/action_controller/session_management.rb +26 -134
  54. data/lib/action_controller/streaming.rb +24 -7
  55. data/lib/action_controller/templates/rescues/diagnostics.erb +2 -2
  56. data/lib/action_controller/templates/rescues/template_error.erb +2 -2
  57. data/lib/action_controller/test_case.rb +87 -30
  58. data/lib/action_controller/test_process.rb +145 -104
  59. data/lib/action_controller/uploaded_file.rb +44 -0
  60. data/lib/action_controller/url_rewriter.rb +3 -6
  61. data/lib/action_controller/vendor/html-scanner.rb +16 -0
  62. data/lib/action_controller/vendor/html-scanner/html/selector.rb +1 -1
  63. data/lib/action_controller/vendor/rack-1.0/rack.rb +89 -0
  64. data/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +22 -0
  65. data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +37 -0
  66. data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +37 -0
  67. data/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +58 -0
  68. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +124 -0
  69. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +51 -0
  70. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +55 -0
  71. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +40 -0
  72. data/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +480 -0
  73. data/lib/action_controller/vendor/rack-1.0/rack/builder.rb +63 -0
  74. data/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +36 -0
  75. data/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +49 -0
  76. data/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +61 -0
  77. data/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +45 -0
  78. data/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +29 -0
  79. data/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +23 -0
  80. data/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +85 -0
  81. data/lib/action_controller/vendor/rack-1.0/rack/directory.rb +153 -0
  82. data/lib/action_controller/vendor/rack-1.0/rack/file.rb +88 -0
  83. data/lib/action_controller/vendor/rack-1.0/rack/handler.rb +48 -0
  84. data/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +61 -0
  85. data/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +8 -0
  86. data/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +89 -0
  87. data/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +55 -0
  88. data/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +84 -0
  89. data/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +59 -0
  90. data/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +8 -0
  91. data/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +18 -0
  92. data/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +67 -0
  93. data/lib/action_controller/vendor/rack-1.0/rack/head.rb +19 -0
  94. data/lib/action_controller/vendor/rack-1.0/rack/lint.rb +462 -0
  95. data/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +65 -0
  96. data/lib/action_controller/vendor/rack-1.0/rack/lock.rb +16 -0
  97. data/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +27 -0
  98. data/lib/action_controller/vendor/rack-1.0/rack/mime.rb +204 -0
  99. data/lib/action_controller/vendor/rack-1.0/rack/mock.rb +160 -0
  100. data/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +57 -0
  101. data/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +64 -0
  102. data/lib/action_controller/vendor/rack-1.0/rack/request.rb +241 -0
  103. data/lib/action_controller/vendor/rack-1.0/rack/response.rb +179 -0
  104. data/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +142 -0
  105. data/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +91 -0
  106. data/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +109 -0
  107. data/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +100 -0
  108. data/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +349 -0
  109. data/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +106 -0
  110. data/lib/action_controller/vendor/rack-1.0/rack/static.rb +38 -0
  111. data/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +55 -0
  112. data/lib/action_controller/vendor/rack-1.0/rack/utils.rb +392 -0
  113. data/lib/action_controller/verification.rb +1 -1
  114. data/lib/action_pack.rb +1 -1
  115. data/lib/action_pack/version.rb +2 -2
  116. data/lib/action_view.rb +22 -17
  117. data/lib/action_view/base.rb +53 -79
  118. data/lib/action_view/erb/util.rb +38 -0
  119. data/lib/action_view/helpers.rb +24 -5
  120. data/lib/action_view/helpers/active_record_helper.rb +2 -2
  121. data/lib/action_view/helpers/asset_tag_helper.rb +81 -50
  122. data/lib/action_view/helpers/atom_feed_helper.rb +1 -1
  123. data/lib/action_view/helpers/benchmark_helper.rb +26 -5
  124. data/lib/action_view/helpers/date_helper.rb +82 -7
  125. data/lib/action_view/helpers/form_helper.rb +295 -64
  126. data/lib/action_view/helpers/form_options_helper.rb +160 -18
  127. data/lib/action_view/helpers/form_tag_helper.rb +2 -2
  128. data/lib/action_view/helpers/number_helper.rb +31 -18
  129. data/lib/action_view/helpers/prototype_helper.rb +2 -12
  130. data/lib/action_view/helpers/sanitize_helper.rb +0 -10
  131. data/lib/action_view/helpers/scriptaculous_helper.rb +1 -0
  132. data/lib/action_view/helpers/tag_helper.rb +3 -4
  133. data/lib/action_view/helpers/text_helper.rb +99 -122
  134. data/lib/action_view/helpers/translation_helper.rb +19 -1
  135. data/lib/action_view/helpers/url_helper.rb +25 -2
  136. data/lib/action_view/inline_template.rb +1 -1
  137. data/lib/action_view/locale/en.yml +19 -1
  138. data/lib/action_view/partials.rb +46 -9
  139. data/lib/action_view/paths.rb +28 -84
  140. data/lib/action_view/reloadable_template.rb +117 -0
  141. data/lib/action_view/renderable.rb +28 -35
  142. data/lib/action_view/renderable_partial.rb +3 -4
  143. data/lib/action_view/template.rb +172 -31
  144. data/lib/action_view/template_error.rb +8 -9
  145. data/lib/action_view/template_handler.rb +1 -1
  146. data/lib/action_view/template_handlers.rb +9 -6
  147. data/lib/action_view/template_handlers/erb.rb +2 -39
  148. data/lib/action_view/template_handlers/rjs.rb +1 -0
  149. data/lib/action_view/test_case.rb +27 -1
  150. data/test/abstract_unit.rb +23 -17
  151. data/test/active_record_unit.rb +5 -4
  152. data/test/activerecord/active_record_store_test.rb +139 -106
  153. data/test/activerecord/render_partial_with_record_identification_test.rb +5 -21
  154. data/test/controller/action_pack_assertions_test.rb +25 -23
  155. data/test/controller/addresses_render_test.rb +3 -6
  156. data/test/controller/assert_select_test.rb +83 -70
  157. data/test/controller/base_test.rb +11 -13
  158. data/test/controller/benchmark_test.rb +3 -3
  159. data/test/controller/caching_test.rb +34 -24
  160. data/test/controller/capture_test.rb +3 -6
  161. data/test/controller/content_type_test.rb +3 -6
  162. data/test/controller/cookie_test.rb +31 -66
  163. data/test/controller/deprecation/deprecated_base_methods_test.rb +9 -11
  164. data/test/controller/dispatcher_test.rb +23 -28
  165. data/test/controller/fake_models.rb +8 -0
  166. data/test/controller/filters_test.rb +6 -2
  167. data/test/controller/flash_test.rb +2 -6
  168. data/test/controller/helper_test.rb +15 -1
  169. data/test/controller/html-scanner/document_test.rb +1 -1
  170. data/test/controller/html-scanner/sanitizer_test.rb +1 -1
  171. data/test/controller/http_basic_authentication_test.rb +88 -0
  172. data/test/controller/http_digest_authentication_test.rb +178 -0
  173. data/test/controller/integration_test.rb +56 -52
  174. data/test/controller/layout_test.rb +46 -44
  175. data/test/controller/middleware_stack_test.rb +90 -0
  176. data/test/controller/mime_responds_test.rb +7 -11
  177. data/test/controller/mime_type_test.rb +9 -0
  178. data/test/controller/polymorphic_routes_test.rb +235 -151
  179. data/test/controller/rack_test.rb +52 -81
  180. data/test/controller/redirect_test.rb +6 -14
  181. data/test/controller/render_test.rb +273 -60
  182. data/test/controller/request/json_params_parsing_test.rb +45 -0
  183. data/test/controller/request/multipart_params_parsing_test.rb +223 -0
  184. data/test/controller/request/query_string_parsing_test.rb +120 -0
  185. data/test/controller/request/url_encoded_params_parsing_test.rb +184 -0
  186. data/test/controller/request/xml_params_parsing_test.rb +88 -0
  187. data/test/controller/request_forgery_protection_test.rb +17 -98
  188. data/test/controller/request_test.rb +45 -530
  189. data/test/controller/rescue_test.rb +45 -22
  190. data/test/controller/resources_test.rb +112 -37
  191. data/test/controller/routing_test.rb +1442 -1384
  192. data/test/controller/selector_test.rb +3 -3
  193. data/test/controller/send_file_test.rb +30 -3
  194. data/test/controller/session/cookie_store_test.rb +169 -240
  195. data/test/controller/session/mem_cache_store_test.rb +94 -148
  196. data/test/controller/session/test_session_test.rb +58 -0
  197. data/test/controller/test_test.rb +32 -13
  198. data/test/controller/url_rewriter_test.rb +54 -4
  199. data/test/controller/verification_test.rb +1 -1
  200. data/test/controller/view_paths_test.rb +15 -15
  201. data/test/controller/webservice_test.rb +178 -147
  202. data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
  203. data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
  204. data/test/fixtures/layouts/default_html.html.erb +1 -0
  205. data/test/fixtures/layouts/xhr.html.erb +2 -0
  206. data/test/fixtures/multipart/empty +10 -0
  207. data/test/fixtures/multipart/hello.txt +1 -0
  208. data/test/fixtures/multipart/none +9 -0
  209. data/test/fixtures/public/500.da.html +1 -0
  210. data/test/fixtures/quiz/questions/_question.html.erb +1 -0
  211. data/test/fixtures/replies.yml +1 -1
  212. data/test/fixtures/test/_one.html.erb +1 -0
  213. data/test/fixtures/test/_two.html.erb +1 -0
  214. data/test/fixtures/test/dont_pick_me +1 -0
  215. data/test/fixtures/test/hello.builder +1 -1
  216. data/test/fixtures/test/hello_world.da.html.erb +1 -0
  217. data/test/fixtures/test/hello_world.erb~ +1 -0
  218. data/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
  219. data/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
  220. data/test/fixtures/test/malformed/malformed.erb~ +1 -0
  221. data/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
  222. data/test/fixtures/test/render_explicit_html_template.js.rjs +1 -0
  223. data/test/fixtures/test/render_implicit_html_template.js.rjs +1 -0
  224. data/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
  225. data/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
  226. data/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +1 -0
  227. data/test/fixtures/test/utf8.html.erb +2 -0
  228. data/test/template/active_record_helper_i18n_test.rb +31 -33
  229. data/test/template/active_record_helper_test.rb +34 -0
  230. data/test/template/asset_tag_helper_test.rb +52 -14
  231. data/test/template/atom_feed_helper_test.rb +3 -5
  232. data/test/template/benchmark_helper_test.rb +50 -24
  233. data/test/template/compiled_templates_test.rb +177 -33
  234. data/test/template/date_helper_i18n_test.rb +88 -81
  235. data/test/template/date_helper_test.rb +427 -43
  236. data/test/template/form_helper_test.rb +243 -44
  237. data/test/template/form_options_helper_test.rb +631 -565
  238. data/test/template/form_tag_helper_test.rb +9 -2
  239. data/test/template/javascript_helper_test.rb +0 -5
  240. data/test/template/number_helper_i18n_test.rb +60 -48
  241. data/test/template/number_helper_test.rb +1 -0
  242. data/test/template/render_test.rb +117 -35
  243. data/test/template/test_test.rb +4 -6
  244. data/test/template/text_helper_test.rb +129 -50
  245. data/test/template/translation_helper_test.rb +23 -19
  246. data/test/template/url_helper_test.rb +35 -2
  247. data/test/view/test_case_test.rb +8 -0
  248. metadata +197 -23
  249. data/lib/action_controller/assertions.rb +0 -69
  250. data/lib/action_controller/caching/sql_cache.rb +0 -18
  251. data/lib/action_controller/cgi_ext/session.rb +0 -53
  252. data/lib/action_controller/components.rb +0 -169
  253. data/lib/action_controller/rack_process.rb +0 -297
  254. data/lib/action_controller/request_profiler.rb +0 -169
  255. data/lib/action_controller/session/active_record_store.rb +0 -340
  256. data/lib/action_controller/session/drb_server.rb +0 -32
  257. data/lib/action_controller/session/drb_store.rb +0 -35
  258. data/test/controller/cgi_test.rb +0 -269
  259. data/test/controller/components_test.rb +0 -156
  260. data/test/controller/http_authentication_test.rb +0 -54
  261. data/test/controller/integration_upload_test.rb +0 -43
  262. data/test/controller/session_fixation_test.rb +0 -89
  263. data/test/controller/session_management_test.rb +0 -178
  264. data/test/fixtures/test/hello_world.js +0 -1
@@ -15,21 +15,31 @@ silence_warnings do
15
15
  def new_record?
16
16
  @new_record
17
17
  end
18
+
19
+ attr_accessor :author
20
+ def author_attributes=(attributes); end
21
+
22
+ attr_accessor :comments
23
+ def comments_attributes=(attributes); end
18
24
  end
19
25
 
20
26
  class Comment
21
27
  attr_reader :id
22
28
  attr_reader :post_id
29
+ def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
23
30
  def save; @id = 1; @post_id = 1 end
24
31
  def new_record?; @id.nil? end
25
32
  def to_param; @id; end
26
33
  def name
27
- @id.nil? ? 'new comment' : "comment ##{@id}"
34
+ @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
28
35
  end
29
36
  end
30
- end
31
37
 
32
- class Comment::Nested < Comment; end
38
+ class Author < Comment
39
+ attr_accessor :post
40
+ def post_attributes=(attributes); end
41
+ end
42
+ end
33
43
 
34
44
  class FormHelperTest < ActionView::TestCase
35
45
  tests ActionView::Helpers::FormHelper
@@ -160,36 +170,36 @@ class FormHelperTest < ActionView::TestCase
160
170
 
161
171
  def test_check_box
162
172
  assert_dom_equal(
163
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
173
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
164
174
  check_box("post", "secret")
165
175
  )
166
176
  @post.secret = 0
167
177
  assert_dom_equal(
168
- '<input id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
178
+ '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
169
179
  check_box("post", "secret")
170
180
  )
171
181
  assert_dom_equal(
172
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
182
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
173
183
  check_box("post", "secret" ,{"checked"=>"checked"})
174
184
  )
175
185
  @post.secret = true
176
186
  assert_dom_equal(
177
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
187
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
178
188
  check_box("post", "secret")
179
189
  )
180
190
  assert_dom_equal(
181
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
191
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
182
192
  check_box("post", "secret?")
183
193
  )
184
194
 
185
195
  @post.secret = ['0']
186
196
  assert_dom_equal(
187
- '<input id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
197
+ '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
188
198
  check_box("post", "secret")
189
199
  )
190
200
  @post.secret = ['1']
191
201
  assert_dom_equal(
192
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
202
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
193
203
  check_box("post", "secret")
194
204
  )
195
205
  end
@@ -197,14 +207,14 @@ class FormHelperTest < ActionView::TestCase
197
207
  def test_check_box_with_explicit_checked_and_unchecked_values
198
208
  @post.secret = "on"
199
209
  assert_dom_equal(
200
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" /><input name="post[secret]" type="hidden" value="off" />',
210
+ '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
201
211
  check_box("post", "secret", {}, "on", "off")
202
212
  )
203
213
  end
204
214
 
205
215
  def test_checkbox_disabled_still_submits_checked_value
206
216
  assert_dom_equal(
207
- '<input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="1" />',
217
+ '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
208
218
  check_box("post", "secret", { :disabled => :true })
209
219
  )
210
220
  end
@@ -279,7 +289,7 @@ class FormHelperTest < ActionView::TestCase
279
289
  text_area("post", "body", "name" => "really!")
280
290
  )
281
291
  assert_dom_equal(
282
- '<input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" /><input name="i mean it" type="hidden" value="0" />',
292
+ '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />',
283
293
  check_box("post", "secret", "name" => "i mean it")
284
294
  )
285
295
  assert_dom_equal text_field("post", "title", "name" => "dont guess"),
@@ -299,7 +309,7 @@ class FormHelperTest < ActionView::TestCase
299
309
  text_area("post", "body", "id" => "really!")
300
310
  )
301
311
  assert_dom_equal(
302
- '<input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
312
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />',
303
313
  check_box("post", "secret", "id" => "i mean it")
304
314
  )
305
315
  assert_dom_equal text_field("post", "title", "id" => "dont guess"),
@@ -324,7 +334,7 @@ class FormHelperTest < ActionView::TestCase
324
334
  text_area("post[]", "body")
325
335
  )
326
336
  assert_dom_equal(
327
- "<input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" /><input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" />",
337
+ "<input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" /><input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" />",
328
338
  check_box("post[]", "secret")
329
339
  )
330
340
  assert_dom_equal(
@@ -350,8 +360,8 @@ class FormHelperTest < ActionView::TestCase
350
360
  "<label for='post_title'>Title</label>" +
351
361
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
352
362
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
353
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
354
363
  "<input name='post[secret]' type='hidden' value='0' />" +
364
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
355
365
  "<input name='commit' id='post_submit' type='submit' value='Create post' />" +
356
366
  "</form>"
357
367
 
@@ -370,8 +380,8 @@ class FormHelperTest < ActionView::TestCase
370
380
  "<div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div>" +
371
381
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
372
382
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
373
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
374
383
  "<input name='post[secret]' type='hidden' value='0' />" +
384
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
375
385
  "</form>"
376
386
 
377
387
  assert_dom_equal expected, output_buffer
@@ -388,8 +398,8 @@ class FormHelperTest < ActionView::TestCase
388
398
  "<form action='http://www.example.com' id='create-post' method='post'>" +
389
399
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
390
400
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
391
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
392
401
  "<input name='post[secret]' type='hidden' value='0' />" +
402
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
393
403
  "</form>"
394
404
 
395
405
  assert_dom_equal expected, output_buffer
@@ -408,8 +418,8 @@ class FormHelperTest < ActionView::TestCase
408
418
  "<label for=\"post_123_title\">Title</label>" +
409
419
  "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
410
420
  "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
411
- "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" +
412
421
  "<input name='post[123][secret]' type='hidden' value='0' />" +
422
+ "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" +
413
423
  "</form>"
414
424
 
415
425
  assert_dom_equal expected, output_buffer
@@ -426,8 +436,8 @@ class FormHelperTest < ActionView::TestCase
426
436
  "<form action='http://www.example.com' method='post'>" +
427
437
  "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" +
428
438
  "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
429
- "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" +
430
439
  "<input name='post[][secret]' type='hidden' value='0' />" +
440
+ "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" +
431
441
  "</form>"
432
442
 
433
443
  assert_dom_equal expected, output_buffer
@@ -463,7 +473,7 @@ class FormHelperTest < ActionView::TestCase
463
473
  assert_dom_equal expected, output_buffer
464
474
  end
465
475
 
466
- def test_nested_fields_for_with_index
476
+ def test_nested_fields_for_with_index_and_parent_fields
467
477
  form_for('post', @post, :index => 1) do |c|
468
478
  concat c.text_field(:title)
469
479
  c.fields_for('comment', @comment, :index => 1) do |r|
@@ -479,7 +489,7 @@ class FormHelperTest < ActionView::TestCase
479
489
  assert_dom_equal expected, output_buffer
480
490
  end
481
491
 
482
- def test_nested_fields_for_with_index
492
+ def test_form_for_with_index_and_nested_fields_for
483
493
  form_for(:post, @post, :index => 1) do |f|
484
494
  f.fields_for(:comment, @post) do |c|
485
495
  concat c.text_field(:title)
@@ -558,6 +568,158 @@ class FormHelperTest < ActionView::TestCase
558
568
  assert_dom_equal expected, output_buffer
559
569
  end
560
570
 
571
+ def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association
572
+ @post.author = Author.new
573
+
574
+ form_for(:post, @post) do |f|
575
+ concat f.text_field(:title)
576
+ f.fields_for(:author) do |af|
577
+ concat af.text_field(:name)
578
+ end
579
+ end
580
+
581
+ expected = '<form action="http://www.example.com" method="post">' +
582
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
583
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />' +
584
+ '</form>'
585
+
586
+ assert_dom_equal expected, output_buffer
587
+ end
588
+
589
+ def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association
590
+ form_for(:post, @post) do |f|
591
+ f.fields_for(:author, Author.new(123)) do |af|
592
+ assert_not_nil af.object
593
+ assert_equal 123, af.object.id
594
+ end
595
+ end
596
+ end
597
+
598
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association
599
+ @post.author = Author.new(321)
600
+
601
+ form_for(:post, @post) do |f|
602
+ concat f.text_field(:title)
603
+ f.fields_for(:author) do |af|
604
+ concat af.text_field(:name)
605
+ end
606
+ end
607
+
608
+ expected = '<form action="http://www.example.com" method="post">' +
609
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
610
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
611
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
612
+ '</form>'
613
+
614
+ assert_dom_equal expected, output_buffer
615
+ end
616
+
617
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association
618
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
619
+
620
+ form_for(:post, @post) do |f|
621
+ concat f.text_field(:title)
622
+ @post.comments.each do |comment|
623
+ f.fields_for(:comments, comment) do |cf|
624
+ concat cf.text_field(:name)
625
+ end
626
+ end
627
+ end
628
+
629
+ expected = '<form action="http://www.example.com" method="post">' +
630
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
631
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
632
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
633
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' +
634
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' +
635
+ '</form>'
636
+
637
+ assert_dom_equal expected, output_buffer
638
+ end
639
+
640
+ def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association
641
+ @post.comments = [Comment.new, Comment.new]
642
+
643
+ form_for(:post, @post) do |f|
644
+ concat f.text_field(:title)
645
+ @post.comments.each do |comment|
646
+ f.fields_for(:comments, comment) do |cf|
647
+ concat cf.text_field(:name)
648
+ end
649
+ end
650
+ end
651
+
652
+ expected = '<form action="http://www.example.com" method="post">' +
653
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
654
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" />' +
655
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
656
+ '</form>'
657
+
658
+ assert_dom_equal expected, output_buffer
659
+ end
660
+
661
+ def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association
662
+ @post.comments = [Comment.new(321), Comment.new]
663
+
664
+ form_for(:post, @post) do |f|
665
+ concat f.text_field(:title)
666
+ @post.comments.each do |comment|
667
+ f.fields_for(:comments, comment) do |cf|
668
+ concat cf.text_field(:name)
669
+ end
670
+ end
671
+ end
672
+
673
+ expected = '<form action="http://www.example.com" method="post">' +
674
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
675
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
676
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
677
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
678
+ '</form>'
679
+
680
+ assert_dom_equal expected, output_buffer
681
+ end
682
+
683
+ def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder
684
+ @post.comments = [Comment.new(321), Comment.new]
685
+ yielded_comments = []
686
+
687
+ form_for(:post, @post) do |f|
688
+ concat f.text_field(:title)
689
+ f.fields_for(:comments) do |cf|
690
+ concat cf.text_field(:name)
691
+ yielded_comments << cf.object
692
+ end
693
+ end
694
+
695
+ expected = '<form action="http://www.example.com" method="post">' +
696
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
697
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
698
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
699
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
700
+ '</form>'
701
+
702
+ assert_dom_equal expected, output_buffer
703
+ assert_equal yielded_comments, @post.comments
704
+ end
705
+
706
+ def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association
707
+ @post.comments = []
708
+
709
+ form_for(:post, @post) do |f|
710
+ f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf|
711
+ concat cf.text_field(:name)
712
+ end
713
+ end
714
+
715
+ expected = '<form action="http://www.example.com" method="post">' +
716
+ '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />' +
717
+ '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" size="30" type="text" value="comment #321" />' +
718
+ '</form>'
719
+
720
+ assert_dom_equal expected, output_buffer
721
+ end
722
+
561
723
  def test_fields_for
562
724
  fields_for(:post, @post) do |f|
563
725
  concat f.text_field(:title)
@@ -568,8 +730,8 @@ class FormHelperTest < ActionView::TestCase
568
730
  expected =
569
731
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
570
732
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
571
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
572
- "<input name='post[secret]' type='hidden' value='0' />"
733
+ "<input name='post[secret]' type='hidden' value='0' />" +
734
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
573
735
 
574
736
  assert_dom_equal expected, output_buffer
575
737
  end
@@ -584,8 +746,8 @@ class FormHelperTest < ActionView::TestCase
584
746
  expected =
585
747
  "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
586
748
  "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
587
- "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" +
588
- "<input name='post[123][secret]' type='hidden' value='0' />"
749
+ "<input name='post[123][secret]' type='hidden' value='0' />" +
750
+ "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"
589
751
 
590
752
  assert_dom_equal expected, output_buffer
591
753
  end
@@ -600,8 +762,8 @@ class FormHelperTest < ActionView::TestCase
600
762
  expected =
601
763
  "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" +
602
764
  "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
603
- "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" +
604
- "<input name='post[][secret]' type='hidden' value='0' />"
765
+ "<input name='post[][secret]' type='hidden' value='0' />" +
766
+ "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"
605
767
 
606
768
  assert_dom_equal expected, output_buffer
607
769
  end
@@ -616,8 +778,8 @@ class FormHelperTest < ActionView::TestCase
616
778
  expected =
617
779
  "<input name='post[abc][title]' size='30' type='text' id='post_abc_title' value='Hello World' />" +
618
780
  "<textarea name='post[abc][body]' id='post_abc_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
619
- "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />" +
620
- "<input name='post[abc][secret]' type='hidden' value='0' />"
781
+ "<input name='post[abc][secret]' type='hidden' value='0' />" +
782
+ "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />"
621
783
 
622
784
  assert_dom_equal expected, output_buffer
623
785
  end
@@ -632,8 +794,8 @@ class FormHelperTest < ActionView::TestCase
632
794
  expected =
633
795
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
634
796
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
635
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
636
- "<input name='post[secret]' type='hidden' value='0' />"
797
+ "<input name='post[secret]' type='hidden' value='0' />" +
798
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
637
799
 
638
800
  assert_dom_equal expected, output_buffer
639
801
  end
@@ -648,8 +810,8 @@ class FormHelperTest < ActionView::TestCase
648
810
  expected =
649
811
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
650
812
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
651
- "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
652
- "<input name='post[secret]' type='hidden' value='0' />"
813
+ "<input name='post[secret]' type='hidden' value='0' />" +
814
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
653
815
 
654
816
  assert_dom_equal expected, output_buffer
655
817
  end
@@ -694,8 +856,8 @@ class FormHelperTest < ActionView::TestCase
694
856
  "<form action='http://www.example.com' id='create-post' method='post'>" +
695
857
  "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
696
858
  "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
697
- "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" +
698
859
  "<input name='parent_post[secret]' type='hidden' value='0' />" +
860
+ "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" +
699
861
  "</form>"
700
862
 
701
863
  assert_dom_equal expected, output_buffer
@@ -743,8 +905,7 @@ class FormHelperTest < ActionView::TestCase
743
905
  "<form action='http://www.example.com' method='post'>" +
744
906
  "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
745
907
  "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
746
- "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
747
- "<input name='post[secret]' type='hidden' value='0' /><br/>" +
908
+ "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" +
748
909
  "</form>"
749
910
 
750
911
  assert_dom_equal expected, output_buffer
@@ -764,8 +925,7 @@ class FormHelperTest < ActionView::TestCase
764
925
  "<form action='http://www.example.com' method='post'>" +
765
926
  "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
766
927
  "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
767
- "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
768
- "<input name='post[secret]' type='hidden' value='0' /><br/>" +
928
+ "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" +
769
929
  "</form>"
770
930
 
771
931
  assert_dom_equal expected, output_buffer
@@ -820,8 +980,7 @@ class FormHelperTest < ActionView::TestCase
820
980
  %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) +
821
981
  "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
822
982
  "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
823
- "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
824
- "<input name='post[secret]' type='hidden' value='0' /><br/>" +
983
+ "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" +
825
984
  "</form>"
826
985
 
827
986
  assert_dom_equal expected, output_buffer
@@ -837,12 +996,52 @@ class FormHelperTest < ActionView::TestCase
837
996
  expected =
838
997
  "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
839
998
  "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
840
- "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
841
- "<input name='post[secret]' type='hidden' value='0' /><br/>"
999
+ "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
842
1000
 
843
1001
  assert_dom_equal expected, output_buffer
844
1002
  end
845
1003
 
1004
+ def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash
1005
+ klass = nil
1006
+
1007
+ form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
1008
+ f.fields_for(:comments, Comment.new) do |nested_fields|
1009
+ klass = nested_fields.class
1010
+ ''
1011
+ end
1012
+ end
1013
+
1014
+ assert_equal LabelledFormBuilder, klass
1015
+ end
1016
+
1017
+ def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash
1018
+ klass = nil
1019
+
1020
+ form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
1021
+ f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields|
1022
+ klass = nested_fields.class
1023
+ ''
1024
+ end
1025
+ end
1026
+
1027
+ assert_equal LabelledFormBuilder, klass
1028
+ end
1029
+
1030
+ class LabelledFormBuilderSubclass < LabelledFormBuilder; end
1031
+
1032
+ def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder
1033
+ klass = nil
1034
+
1035
+ form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
1036
+ f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields|
1037
+ klass = nested_fields.class
1038
+ ''
1039
+ end
1040
+ end
1041
+
1042
+ assert_equal LabelledFormBuilderSubclass, klass
1043
+ end
1044
+
846
1045
  def test_form_for_with_html_options_adds_options_to_form_tag
847
1046
  form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
848
1047
  expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>"
@@ -974,4 +1173,4 @@ class FormHelperTest < ActionView::TestCase
974
1173
  def protect_against_forgery?
975
1174
  false
976
1175
  end
977
- end
1176
+ end