jets 1.4.11 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1027) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile.lock +6 -5
  5. data/jets.gemspec +3 -2
  6. data/lib/jets.rb +8 -2
  7. data/lib/jets/builders/tidy.rb +2 -1
  8. data/lib/jets/commands/db.rb +3 -3
  9. data/lib/jets/commands/db/tasks.rb +5 -4
  10. data/lib/jets/generator.rb +3 -2
  11. data/lib/jets/router.rb +29 -4
  12. data/lib/jets/router/scope.rb +30 -0
  13. data/lib/jets/version.rb +1 -1
  14. data/vendor/rails/Brewfile +13 -0
  15. data/vendor/rails/CODE_OF_CONDUCT.md +12 -0
  16. data/vendor/rails/CONTRIBUTING.md +49 -0
  17. data/vendor/rails/Gemfile +174 -0
  18. data/vendor/rails/Gemfile.lock +564 -0
  19. data/vendor/rails/MIT-LICENSE +20 -0
  20. data/vendor/rails/RAILS_VERSION +1 -0
  21. data/vendor/rails/README.md +97 -0
  22. data/vendor/rails/RELEASING_RAILS.md +225 -0
  23. data/vendor/rails/Rakefile +72 -0
  24. data/vendor/rails/actionpack/CHANGELOG.md +407 -0
  25. data/vendor/rails/actionpack/MIT-LICENSE +21 -0
  26. data/vendor/rails/actionpack/README.rdoc +57 -0
  27. data/vendor/rails/actionpack/Rakefile +40 -0
  28. data/vendor/rails/actionpack/actionpack.gemspec +38 -0
  29. data/vendor/rails/actionpack/bin/test +5 -0
  30. data/vendor/rails/actionpack/lib/abstract_controller.rb +27 -0
  31. data/vendor/rails/actionpack/lib/abstract_controller/asset_paths.rb +12 -0
  32. data/vendor/rails/actionpack/lib/abstract_controller/base.rb +265 -0
  33. data/vendor/rails/actionpack/lib/abstract_controller/caching.rb +66 -0
  34. data/vendor/rails/actionpack/lib/abstract_controller/caching/fragments.rb +166 -0
  35. data/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb +212 -0
  36. data/vendor/rails/actionpack/lib/abstract_controller/collector.rb +43 -0
  37. data/vendor/rails/actionpack/lib/abstract_controller/error.rb +6 -0
  38. data/vendor/rails/actionpack/lib/abstract_controller/helpers.rb +194 -0
  39. data/vendor/rails/actionpack/lib/abstract_controller/logger.rb +14 -0
  40. data/vendor/rails/actionpack/lib/abstract_controller/railties/routes_helpers.rb +20 -0
  41. data/vendor/rails/actionpack/lib/abstract_controller/rendering.rb +127 -0
  42. data/vendor/rails/actionpack/lib/abstract_controller/translation.rb +31 -0
  43. data/vendor/rails/actionpack/lib/abstract_controller/url_for.rb +35 -0
  44. data/vendor/rails/actionpack/lib/action_controller.rb +66 -0
  45. data/vendor/rails/actionpack/lib/action_controller/api.rb +149 -0
  46. data/vendor/rails/actionpack/lib/action_controller/api/api_rendering.rb +16 -0
  47. data/vendor/rails/actionpack/lib/action_controller/base.rb +276 -0
  48. data/vendor/rails/actionpack/lib/action_controller/caching.rb +46 -0
  49. data/vendor/rails/actionpack/lib/action_controller/form_builder.rb +50 -0
  50. data/vendor/rails/actionpack/lib/action_controller/log_subscriber.rb +78 -0
  51. data/vendor/rails/actionpack/lib/action_controller/metal.rb +256 -0
  52. data/vendor/rails/actionpack/lib/action_controller/metal/basic_implicit_render.rb +13 -0
  53. data/vendor/rails/actionpack/lib/action_controller/metal/conditional_get.rb +274 -0
  54. data/vendor/rails/actionpack/lib/action_controller/metal/content_security_policy.rb +52 -0
  55. data/vendor/rails/actionpack/lib/action_controller/metal/cookies.rb +16 -0
  56. data/vendor/rails/actionpack/lib/action_controller/metal/data_streaming.rb +152 -0
  57. data/vendor/rails/actionpack/lib/action_controller/metal/etag_with_flash.rb +18 -0
  58. data/vendor/rails/actionpack/lib/action_controller/metal/etag_with_template_digest.rb +57 -0
  59. data/vendor/rails/actionpack/lib/action_controller/metal/exceptions.rb +53 -0
  60. data/vendor/rails/actionpack/lib/action_controller/metal/flash.rb +61 -0
  61. data/vendor/rails/actionpack/lib/action_controller/metal/force_ssl.rb +99 -0
  62. data/vendor/rails/actionpack/lib/action_controller/metal/head.rb +60 -0
  63. data/vendor/rails/actionpack/lib/action_controller/metal/helpers.rb +123 -0
  64. data/vendor/rails/actionpack/lib/action_controller/metal/http_authentication.rb +519 -0
  65. data/vendor/rails/actionpack/lib/action_controller/metal/implicit_render.rb +73 -0
  66. data/vendor/rails/actionpack/lib/action_controller/metal/instrumentation.rb +107 -0
  67. data/vendor/rails/actionpack/lib/action_controller/metal/live.rb +312 -0
  68. data/vendor/rails/actionpack/lib/action_controller/metal/mime_responds.rb +313 -0
  69. data/vendor/rails/actionpack/lib/action_controller/metal/parameter_encoding.rb +51 -0
  70. data/vendor/rails/actionpack/lib/action_controller/metal/params_wrapper.rb +293 -0
  71. data/vendor/rails/actionpack/lib/action_controller/metal/redirecting.rb +133 -0
  72. data/vendor/rails/actionpack/lib/action_controller/metal/renderers.rb +181 -0
  73. data/vendor/rails/actionpack/lib/action_controller/metal/rendering.rb +122 -0
  74. data/vendor/rails/actionpack/lib/action_controller/metal/request_forgery_protection.rb +445 -0
  75. data/vendor/rails/actionpack/lib/action_controller/metal/rescue.rb +28 -0
  76. data/vendor/rails/actionpack/lib/action_controller/metal/streaming.rb +223 -0
  77. data/vendor/rails/actionpack/lib/action_controller/metal/strong_parameters.rb +1086 -0
  78. data/vendor/rails/actionpack/lib/action_controller/metal/testing.rb +16 -0
  79. data/vendor/rails/actionpack/lib/action_controller/metal/url_for.rb +58 -0
  80. data/vendor/rails/actionpack/lib/action_controller/railtie.rb +89 -0
  81. data/vendor/rails/actionpack/lib/action_controller/railties/helpers.rb +24 -0
  82. data/vendor/rails/actionpack/lib/action_controller/renderer.rb +117 -0
  83. data/vendor/rails/actionpack/lib/action_controller/template_assertions.rb +11 -0
  84. data/vendor/rails/actionpack/lib/action_controller/test_case.rb +629 -0
  85. data/vendor/rails/actionpack/lib/action_dispatch.rb +112 -0
  86. data/vendor/rails/actionpack/lib/action_dispatch/http/cache.rb +220 -0
  87. data/vendor/rails/actionpack/lib/action_dispatch/http/content_security_policy.rb +272 -0
  88. data/vendor/rails/actionpack/lib/action_dispatch/http/filter_parameters.rb +84 -0
  89. data/vendor/rails/actionpack/lib/action_dispatch/http/filter_redirect.rb +37 -0
  90. data/vendor/rails/actionpack/lib/action_dispatch/http/headers.rb +132 -0
  91. data/vendor/rails/actionpack/lib/action_dispatch/http/mime_negotiation.rb +170 -0
  92. data/vendor/rails/actionpack/lib/action_dispatch/http/mime_type.rb +342 -0
  93. data/vendor/rails/actionpack/lib/action_dispatch/http/mime_types.rb +50 -0
  94. data/vendor/rails/actionpack/lib/action_dispatch/http/parameter_filter.rb +86 -0
  95. data/vendor/rails/actionpack/lib/action_dispatch/http/parameters.rb +126 -0
  96. data/vendor/rails/actionpack/lib/action_dispatch/http/rack_cache.rb +63 -0
  97. data/vendor/rails/actionpack/lib/action_dispatch/http/request.rb +430 -0
  98. data/vendor/rails/actionpack/lib/action_dispatch/http/response.rb +520 -0
  99. data/vendor/rails/actionpack/lib/action_dispatch/http/upload.rb +84 -0
  100. data/vendor/rails/actionpack/lib/action_dispatch/http/url.rb +350 -0
  101. data/vendor/rails/actionpack/lib/action_dispatch/journey.rb +7 -0
  102. data/vendor/rails/actionpack/lib/action_dispatch/journey/formatter.rb +189 -0
  103. data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/builder.rb +164 -0
  104. data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/simulator.rb +41 -0
  105. data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb +158 -0
  106. data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/builder.rb +78 -0
  107. data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/dot.rb +36 -0
  108. data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/simulator.rb +49 -0
  109. data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
  110. data/vendor/rails/actionpack/lib/action_dispatch/journey/nodes/node.rb +140 -0
  111. data/vendor/rails/actionpack/lib/action_dispatch/journey/parser.rb +199 -0
  112. data/vendor/rails/actionpack/lib/action_dispatch/journey/parser.y +50 -0
  113. data/vendor/rails/actionpack/lib/action_dispatch/journey/parser_extras.rb +31 -0
  114. data/vendor/rails/actionpack/lib/action_dispatch/journey/path/pattern.rb +198 -0
  115. data/vendor/rails/actionpack/lib/action_dispatch/journey/route.rb +203 -0
  116. data/vendor/rails/actionpack/lib/action_dispatch/journey/router.rb +156 -0
  117. data/vendor/rails/actionpack/lib/action_dispatch/journey/router/utils.rb +102 -0
  118. data/vendor/rails/actionpack/lib/action_dispatch/journey/routes.rb +82 -0
  119. data/vendor/rails/actionpack/lib/action_dispatch/journey/scanner.rb +64 -0
  120. data/vendor/rails/actionpack/lib/action_dispatch/journey/visitors.rb +268 -0
  121. data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
  122. data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
  123. data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
  124. data/vendor/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb +36 -0
  125. data/vendor/rails/actionpack/lib/action_dispatch/middleware/cookies.rb +685 -0
  126. data/vendor/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +205 -0
  127. data/vendor/rails/actionpack/lib/action_dispatch/middleware/debug_locks.rb +124 -0
  128. data/vendor/rails/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +147 -0
  129. data/vendor/rails/actionpack/lib/action_dispatch/middleware/executor.rb +21 -0
  130. data/vendor/rails/actionpack/lib/action_dispatch/middleware/flash.rb +300 -0
  131. data/vendor/rails/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +57 -0
  132. data/vendor/rails/actionpack/lib/action_dispatch/middleware/reloader.rb +12 -0
  133. data/vendor/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb +183 -0
  134. data/vendor/rails/actionpack/lib/action_dispatch/middleware/request_id.rb +43 -0
  135. data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +92 -0
  136. data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/cache_store.rb +54 -0
  137. data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +117 -0
  138. data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb +28 -0
  139. data/vendor/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +62 -0
  140. data/vendor/rails/actionpack/lib/action_dispatch/middleware/ssl.rb +150 -0
  141. data/vendor/rails/actionpack/lib/action_dispatch/middleware/stack.rb +116 -0
  142. data/vendor/rails/actionpack/lib/action_dispatch/middleware/static.rb +130 -0
  143. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +22 -0
  144. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  145. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +27 -0
  146. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  147. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
  148. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
  149. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +16 -0
  150. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  151. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +21 -0
  152. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +13 -0
  153. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb +161 -0
  154. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
  155. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  156. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
  157. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  158. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
  159. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
  160. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
  161. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  162. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
  163. data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb +200 -0
  164. data/vendor/rails/actionpack/lib/action_dispatch/railtie.rb +55 -0
  165. data/vendor/rails/actionpack/lib/action_dispatch/request/session.rb +234 -0
  166. data/vendor/rails/actionpack/lib/action_dispatch/request/utils.rb +78 -0
  167. data/vendor/rails/actionpack/lib/action_dispatch/routing.rb +260 -0
  168. data/vendor/rails/actionpack/lib/action_dispatch/routing/endpoint.rb +17 -0
  169. data/vendor/rails/actionpack/lib/action_dispatch/routing/inspector.rb +225 -0
  170. data/vendor/rails/actionpack/lib/action_dispatch/routing/mapper.rb +2267 -0
  171. data/vendor/rails/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +352 -0
  172. data/vendor/rails/actionpack/lib/action_dispatch/routing/redirection.rb +201 -0
  173. data/vendor/rails/actionpack/lib/action_dispatch/routing/route_set.rb +890 -0
  174. data/vendor/rails/actionpack/lib/action_dispatch/routing/routes_proxy.rb +69 -0
  175. data/vendor/rails/actionpack/lib/action_dispatch/routing/url_for.rb +236 -0
  176. data/vendor/rails/actionpack/lib/action_dispatch/system_test_case.rb +147 -0
  177. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/browser.rb +49 -0
  178. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/driver.rb +59 -0
  179. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/server.rb +31 -0
  180. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +96 -0
  181. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +31 -0
  182. data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +26 -0
  183. data/vendor/rails/actionpack/lib/action_dispatch/testing/assertion_response.rb +47 -0
  184. data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions.rb +24 -0
  185. data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions/response.rb +107 -0
  186. data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions/routing.rb +222 -0
  187. data/vendor/rails/actionpack/lib/action_dispatch/testing/integration.rb +652 -0
  188. data/vendor/rails/actionpack/lib/action_dispatch/testing/request_encoder.rb +55 -0
  189. data/vendor/rails/actionpack/lib/action_dispatch/testing/test_process.rb +50 -0
  190. data/vendor/rails/actionpack/lib/action_dispatch/testing/test_request.rb +71 -0
  191. data/vendor/rails/actionpack/lib/action_dispatch/testing/test_response.rb +53 -0
  192. data/vendor/rails/actionpack/lib/action_pack.rb +26 -0
  193. data/vendor/rails/actionpack/lib/action_pack/gem_version.rb +17 -0
  194. data/vendor/rails/actionpack/lib/action_pack/version.rb +10 -0
  195. data/vendor/rails/actionpack/test/abstract/callbacks_test.rb +270 -0
  196. data/vendor/rails/actionpack/test/abstract/collector_test.rb +65 -0
  197. data/vendor/rails/actionpack/test/abstract/translation_test.rb +79 -0
  198. data/vendor/rails/actionpack/test/abstract_unit.rb +457 -0
  199. data/vendor/rails/actionpack/test/assertions/response_assertions_test.rb +141 -0
  200. data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +493 -0
  201. data/vendor/rails/actionpack/test/controller/api/conditional_get_test.rb +59 -0
  202. data/vendor/rails/actionpack/test/controller/api/data_streaming_test.rb +28 -0
  203. data/vendor/rails/actionpack/test/controller/api/force_ssl_test.rb +22 -0
  204. data/vendor/rails/actionpack/test/controller/api/implicit_render_test.rb +17 -0
  205. data/vendor/rails/actionpack/test/controller/api/params_wrapper_test.rb +28 -0
  206. data/vendor/rails/actionpack/test/controller/api/redirect_to_test.rb +21 -0
  207. data/vendor/rails/actionpack/test/controller/api/renderers_test.rb +50 -0
  208. data/vendor/rails/actionpack/test/controller/api/url_for_test.rb +22 -0
  209. data/vendor/rails/actionpack/test/controller/api/with_cookies_test.rb +23 -0
  210. data/vendor/rails/actionpack/test/controller/api/with_helpers_test.rb +44 -0
  211. data/vendor/rails/actionpack/test/controller/base_test.rb +323 -0
  212. data/vendor/rails/actionpack/test/controller/caching_test.rb +511 -0
  213. data/vendor/rails/actionpack/test/controller/content_type_test.rb +169 -0
  214. data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  215. data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  216. data/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  217. data/vendor/rails/actionpack/test/controller/default_url_options_with_before_action_test.rb +28 -0
  218. data/vendor/rails/actionpack/test/controller/filters_test.rb +1050 -0
  219. data/vendor/rails/actionpack/test/controller/flash_hash_test.rb +216 -0
  220. data/vendor/rails/actionpack/test/controller/flash_test.rb +373 -0
  221. data/vendor/rails/actionpack/test/controller/force_ssl_test.rb +333 -0
  222. data/vendor/rails/actionpack/test/controller/form_builder_test.rb +19 -0
  223. data/vendor/rails/actionpack/test/controller/helper_test.rb +295 -0
  224. data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +179 -0
  225. data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +282 -0
  226. data/vendor/rails/actionpack/test/controller/http_token_authentication_test.rb +216 -0
  227. data/vendor/rails/actionpack/test/controller/integration_test.rb +1136 -0
  228. data/vendor/rails/actionpack/test/controller/live_stream_test.rb +518 -0
  229. data/vendor/rails/actionpack/test/controller/localized_templates_test.rb +48 -0
  230. data/vendor/rails/actionpack/test/controller/log_subscriber_test.rb +371 -0
  231. data/vendor/rails/actionpack/test/controller/metal/renderers_test.rb +50 -0
  232. data/vendor/rails/actionpack/test/controller/metal_test.rb +32 -0
  233. data/vendor/rails/actionpack/test/controller/mime/accept_format_test.rb +94 -0
  234. data/vendor/rails/actionpack/test/controller/mime/respond_to_test.rb +843 -0
  235. data/vendor/rails/actionpack/test/controller/new_base/bare_metal_test.rb +184 -0
  236. data/vendor/rails/actionpack/test/controller/new_base/base_test.rb +131 -0
  237. data/vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb +28 -0
  238. data/vendor/rails/actionpack/test/controller/new_base/content_type_test.rb +116 -0
  239. data/vendor/rails/actionpack/test/controller/new_base/middleware_test.rb +112 -0
  240. data/vendor/rails/actionpack/test/controller/new_base/render_action_test.rb +314 -0
  241. data/vendor/rails/actionpack/test/controller/new_base/render_body_test.rb +172 -0
  242. data/vendor/rails/actionpack/test/controller/new_base/render_context_test.rb +54 -0
  243. data/vendor/rails/actionpack/test/controller/new_base/render_file_test.rb +72 -0
  244. data/vendor/rails/actionpack/test/controller/new_base/render_html_test.rb +192 -0
  245. data/vendor/rails/actionpack/test/controller/new_base/render_implicit_action_test.rb +59 -0
  246. data/vendor/rails/actionpack/test/controller/new_base/render_layout_test.rb +128 -0
  247. data/vendor/rails/actionpack/test/controller/new_base/render_partial_test.rb +62 -0
  248. data/vendor/rails/actionpack/test/controller/new_base/render_plain_test.rb +170 -0
  249. data/vendor/rails/actionpack/test/controller/new_base/render_streaming_test.rb +116 -0
  250. data/vendor/rails/actionpack/test/controller/new_base/render_template_test.rb +240 -0
  251. data/vendor/rails/actionpack/test/controller/new_base/render_test.rb +142 -0
  252. data/vendor/rails/actionpack/test/controller/new_base/render_xml_test.rb +12 -0
  253. data/vendor/rails/actionpack/test/controller/output_escaping_test.rb +17 -0
  254. data/vendor/rails/actionpack/test/controller/parameter_encoding_test.rb +52 -0
  255. data/vendor/rails/actionpack/test/controller/parameters/accessors_test.rb +324 -0
  256. data/vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb +30 -0
  257. data/vendor/rails/actionpack/test/controller/parameters/dup_test.rb +67 -0
  258. data/vendor/rails/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb +70 -0
  259. data/vendor/rails/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb +39 -0
  260. data/vendor/rails/actionpack/test/controller/parameters/mutators_test.rb +122 -0
  261. data/vendor/rails/actionpack/test/controller/parameters/nested_parameters_permit_test.rb +184 -0
  262. data/vendor/rails/actionpack/test/controller/parameters/parameters_permit_test.rb +516 -0
  263. data/vendor/rails/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb +33 -0
  264. data/vendor/rails/actionpack/test/controller/parameters/serialization_test.rb +55 -0
  265. data/vendor/rails/actionpack/test/controller/params_wrapper_test.rb +422 -0
  266. data/vendor/rails/actionpack/test/controller/permitted_params_test.rb +27 -0
  267. data/vendor/rails/actionpack/test/controller/redirect_test.rb +395 -0
  268. data/vendor/rails/actionpack/test/controller/render_js_test.rb +36 -0
  269. data/vendor/rails/actionpack/test/controller/render_json_test.rb +137 -0
  270. data/vendor/rails/actionpack/test/controller/render_test.rb +843 -0
  271. data/vendor/rails/actionpack/test/controller/render_xml_test.rb +102 -0
  272. data/vendor/rails/actionpack/test/controller/renderer_test.rb +136 -0
  273. data/vendor/rails/actionpack/test/controller/renderers_test.rb +91 -0
  274. data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +42 -0
  275. data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +1013 -0
  276. data/vendor/rails/actionpack/test/controller/required_params_test.rb +100 -0
  277. data/vendor/rails/actionpack/test/controller/rescue_test.rb +364 -0
  278. data/vendor/rails/actionpack/test/controller/resources_test.rb +1369 -0
  279. data/vendor/rails/actionpack/test/controller/routing_test.rb +2108 -0
  280. data/vendor/rails/actionpack/test/controller/runner_test.rb +24 -0
  281. data/vendor/rails/actionpack/test/controller/send_file_test.rb +259 -0
  282. data/vendor/rails/actionpack/test/controller/show_exceptions_test.rb +114 -0
  283. data/vendor/rails/actionpack/test/controller/streaming_test.rb +28 -0
  284. data/vendor/rails/actionpack/test/controller/test_case_test.rb +1157 -0
  285. data/vendor/rails/actionpack/test/controller/url_for_integration_test.rb +192 -0
  286. data/vendor/rails/actionpack/test/controller/url_for_test.rb +519 -0
  287. data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +92 -0
  288. data/vendor/rails/actionpack/test/controller/webservice_test.rb +135 -0
  289. data/vendor/rails/actionpack/test/dispatch/callbacks_test.rb +47 -0
  290. data/vendor/rails/actionpack/test/dispatch/content_security_policy_test.rb +525 -0
  291. data/vendor/rails/actionpack/test/dispatch/cookies_test.rb +1345 -0
  292. data/vendor/rails/actionpack/test/dispatch/debug_exceptions_test.rb +502 -0
  293. data/vendor/rails/actionpack/test/dispatch/debug_locks_test.rb +38 -0
  294. data/vendor/rails/actionpack/test/dispatch/exception_wrapper_test.rb +120 -0
  295. data/vendor/rails/actionpack/test/dispatch/executor_test.rb +136 -0
  296. data/vendor/rails/actionpack/test/dispatch/header_test.rb +169 -0
  297. data/vendor/rails/actionpack/test/dispatch/live_response_test.rb +98 -0
  298. data/vendor/rails/actionpack/test/dispatch/mapper_test.rb +210 -0
  299. data/vendor/rails/actionpack/test/dispatch/middleware_stack_test.rb +115 -0
  300. data/vendor/rails/actionpack/test/dispatch/mime_type_test.rb +187 -0
  301. data/vendor/rails/actionpack/test/dispatch/mount_test.rb +95 -0
  302. data/vendor/rails/actionpack/test/dispatch/prefix_generation_test.rb +463 -0
  303. data/vendor/rails/actionpack/test/dispatch/rack_cache_test.rb +23 -0
  304. data/vendor/rails/actionpack/test/dispatch/reloader_test.rb +167 -0
  305. data/vendor/rails/actionpack/test/dispatch/request/json_params_parsing_test.rb +207 -0
  306. data/vendor/rails/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +202 -0
  307. data/vendor/rails/actionpack/test/dispatch/request/query_string_parsing_test.rb +176 -0
  308. data/vendor/rails/actionpack/test/dispatch/request/session_test.rb +165 -0
  309. data/vendor/rails/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +181 -0
  310. data/vendor/rails/actionpack/test/dispatch/request_id_test.rb +75 -0
  311. data/vendor/rails/actionpack/test/dispatch/request_test.rb +1307 -0
  312. data/vendor/rails/actionpack/test/dispatch/response_test.rb +542 -0
  313. data/vendor/rails/actionpack/test/dispatch/routing/concerns_test.rb +124 -0
  314. data/vendor/rails/actionpack/test/dispatch/routing/custom_url_helpers_test.rb +333 -0
  315. data/vendor/rails/actionpack/test/dispatch/routing/inspector_test.rb +425 -0
  316. data/vendor/rails/actionpack/test/dispatch/routing/ipv6_redirect_test.rb +46 -0
  317. data/vendor/rails/actionpack/test/dispatch/routing/route_set_test.rb +166 -0
  318. data/vendor/rails/actionpack/test/dispatch/routing_assertions_test.rb +209 -0
  319. data/vendor/rails/actionpack/test/dispatch/routing_test.rb +5112 -0
  320. data/vendor/rails/actionpack/test/dispatch/runner_test.rb +19 -0
  321. data/vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb +58 -0
  322. data/vendor/rails/actionpack/test/dispatch/session/cache_store_test.rb +183 -0
  323. data/vendor/rails/actionpack/test/dispatch/session/cookie_store_test.rb +417 -0
  324. data/vendor/rails/actionpack/test/dispatch/session/mem_cache_store_test.rb +205 -0
  325. data/vendor/rails/actionpack/test/dispatch/session/test_session_test.rb +65 -0
  326. data/vendor/rails/actionpack/test/dispatch/show_exceptions_test.rb +138 -0
  327. data/vendor/rails/actionpack/test/dispatch/ssl_test.rb +228 -0
  328. data/vendor/rails/actionpack/test/dispatch/static_test.rb +318 -0
  329. data/vendor/rails/actionpack/test/dispatch/system_testing/driver_test.rb +54 -0
  330. data/vendor/rails/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb +81 -0
  331. data/vendor/rails/actionpack/test/dispatch/system_testing/server_test.rb +32 -0
  332. data/vendor/rails/actionpack/test/dispatch/system_testing/system_test_case_test.rb +84 -0
  333. data/vendor/rails/actionpack/test/dispatch/test_request_test.rb +131 -0
  334. data/vendor/rails/actionpack/test/dispatch/test_response_test.rb +37 -0
  335. data/vendor/rails/actionpack/test/dispatch/uploaded_file_test.rb +113 -0
  336. data/vendor/rails/actionpack/test/dispatch/url_generation_test.rb +141 -0
  337. data/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb +1 -0
  338. data/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb +5 -0
  339. data/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
  340. data/vendor/rails/actionpack/test/fixtures/collection_cache/index.html.erb +1 -0
  341. data/vendor/rails/actionpack/test/fixtures/company.rb +11 -0
  342. data/vendor/rails/actionpack/test/fixtures/customers/_commented_customer.html.erb +5 -0
  343. data/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb +4 -0
  344. data/vendor/rails/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb +1 -0
  345. data/vendor/rails/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb +1 -0
  346. data/vendor/rails/actionpack/test/fixtures/functional_caching/_formatted_partial.html.erb +1 -0
  347. data/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb +3 -0
  348. data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
  349. data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
  350. data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb +3 -0
  351. data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +3 -0
  352. data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb +3 -0
  353. data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb +3 -0
  354. data/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
  355. data/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
  356. data/vendor/rails/actionpack/test/fixtures/functional_caching/xml_fragment_cached_with_html_partial.xml.builder +5 -0
  357. data/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
  358. data/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +7 -0
  359. data/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +7 -0
  360. data/vendor/rails/actionpack/test/fixtures/helpers/just_me_helper.rb +5 -0
  361. data/vendor/rails/actionpack/test/fixtures/helpers/me_too_helper.rb +5 -0
  362. data/vendor/rails/actionpack/test/fixtures/helpers1_pack/pack1_helper.rb +7 -0
  363. data/vendor/rails/actionpack/test/fixtures/helpers2_pack/pack2_helper.rb +7 -0
  364. data/vendor/rails/actionpack/test/fixtures/helpers_typo/admin/users_helper.rb +6 -0
  365. data/vendor/rails/actionpack/test/fixtures/implicit_render_test/empty_action_with_mobile_variant.html+mobile.erb +1 -0
  366. data/vendor/rails/actionpack/test/fixtures/implicit_render_test/empty_action_with_template.html.erb +1 -0
  367. data/vendor/rails/actionpack/test/fixtures/layouts/_customers.erb +1 -0
  368. data/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb +3 -0
  369. data/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +3 -0
  370. data/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb +3 -0
  371. data/vendor/rails/actionpack/test/fixtures/layouts/standard.html.erb +1 -0
  372. data/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +2 -0
  373. data/vendor/rails/actionpack/test/fixtures/layouts/with_html_partial.html.erb +1 -0
  374. data/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb +2 -0
  375. data/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +2 -0
  376. data/vendor/rails/actionpack/test/fixtures/load_me.rb +4 -0
  377. data/vendor/rails/actionpack/test/fixtures/localized/hello_world.de.html +1 -0
  378. data/vendor/rails/actionpack/test/fixtures/localized/hello_world.en.html +1 -0
  379. data/vendor/rails/actionpack/test/fixtures/localized/hello_world.it.erb +1 -0
  380. data/vendor/rails/actionpack/test/fixtures/multipart/binary_file +0 -0
  381. data/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file +10 -0
  382. data/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +5 -0
  383. data/vendor/rails/actionpack/test/fixtures/multipart/bracketed_utf8_param +5 -0
  384. data/vendor/rails/actionpack/test/fixtures/multipart/empty +10 -0
  385. data/vendor/rails/actionpack/test/fixtures/multipart/hello.txt +1 -0
  386. data/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +10 -0
  387. data/vendor/rails/actionpack/test/fixtures/multipart/mixed_files +0 -0
  388. data/vendor/rails/actionpack/test/fixtures/multipart/none +9 -0
  389. data/vendor/rails/actionpack/test/fixtures/multipart/ruby_on_rails.jpg +0 -0
  390. data/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +5 -0
  391. data/vendor/rails/actionpack/test/fixtures/multipart/single_utf8_param +5 -0
  392. data/vendor/rails/actionpack/test/fixtures/multipart/text_file +10 -0
  393. data/vendor/rails/actionpack/test/fixtures/multipart/utf8_filename +10 -0
  394. data/vendor/rails/actionpack/test/fixtures/namespaced/implicit_render_test/hello_world.erb +1 -0
  395. data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb +1 -0
  396. data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_for_builder.builder +1 -0
  397. data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_for_erb.erb +1 -0
  398. data/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +1 -0
  399. data/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
  400. data/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +1 -0
  401. data/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +1 -0
  402. data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +1 -0
  403. data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
  404. data/vendor/rails/actionpack/test/fixtures/public/400.html +1 -0
  405. data/vendor/rails/actionpack/test/fixtures/public/404.html +1 -0
  406. data/vendor/rails/actionpack/test/fixtures/public/500.da.html +1 -0
  407. data/vendor/rails/actionpack/test/fixtures/public/500.html +1 -0
  408. data/vendor/rails/actionpack/test/fixtures/public/bar.html +1 -0
  409. data/vendor/rails/actionpack/test/fixtures/public/bar/index.html +1 -0
  410. data/vendor/rails/actionpack/test/fixtures/public/foo/bar.html +1 -0
  411. data/vendor/rails/actionpack/test/fixtures/public/foo/baz.css +3 -0
  412. data/vendor/rails/actionpack/test/fixtures/public/foo/index.html +1 -0
  413. data/vendor/rails/actionpack/test/fixtures/public/foo/other-index.html +1 -0
  414. data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/223/343/202/223/343/201/253/343/201/241/343/201/257.html +1 -0
  415. data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html +1 -0
  416. data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html.gz +0 -0
  417. data/vendor/rails/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
  418. data/vendor/rails/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
  419. data/vendor/rails/actionpack/test/fixtures/public/gzip/foo.zoo +4 -0
  420. data/vendor/rails/actionpack/test/fixtures/public/gzip/foo.zoo.gz +0 -0
  421. data/vendor/rails/actionpack/test/fixtures/public/index.html +1 -0
  422. data/vendor/rails/actionpack/test/fixtures/public/other-index.html +1 -0
  423. data/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
  424. data/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
  425. data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
  426. data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
  427. data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
  428. data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
  429. data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
  430. data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +1 -0
  431. data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
  432. data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
  433. data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
  434. data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
  435. data/vendor/rails/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+phablet.erb +1 -0
  436. data/vendor/rails/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+tablet.erb +1 -0
  437. data/vendor/rails/actionpack/test/fixtures/respond_to/variant_inline_syntax_without_block.html+phone.erb +1 -0
  438. data/vendor/rails/actionpack/test/fixtures/respond_to/variant_plus_none_for_format.html.erb +1 -0
  439. data/vendor/rails/actionpack/test/fixtures/respond_to/variant_with_implicit_template_rendering.html+mobile.erb +1 -0
  440. data/vendor/rails/actionpack/test/fixtures/ruby_template.ruby +2 -0
  441. data/vendor/rails/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +12 -0
  442. data/vendor/rails/actionpack/test/fixtures/shared.html.erb +1 -0
  443. data/vendor/rails/actionpack/test/fixtures/star_star_mime/index.js.erb +1 -0
  444. data/vendor/rails/actionpack/test/fixtures/test/_partial.erb +1 -0
  445. data/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +1 -0
  446. data/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +1 -0
  447. data/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
  448. data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +1 -0
  449. data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
  450. data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
  451. data/vendor/rails/actionpack/test/fixtures/test/hello/hello.erb +1 -0
  452. data/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +1 -0
  453. data/vendor/rails/actionpack/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
  454. data/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +11 -0
  455. data/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder +2 -0
  456. data/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +1 -0
  457. data/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +1 -0
  458. data/vendor/rails/actionpack/test/fixtures/test/with_implicit_template.erb +1 -0
  459. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/bar.html +1 -0
  460. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/bar/index.html +1 -0
  461. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/bar.html +1 -0
  462. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/baz.css +3 -0
  463. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/index.html +1 -0
  464. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/other-index.html +1 -0
  465. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/223/343/202/223/343/201/253/343/201/241/343/201/257.html +1 -0
  466. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html +1 -0
  467. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html.gz +0 -0
  468. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
  469. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
  470. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo +4 -0
  471. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo.gz +0 -0
  472. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/index.html +1 -0
  473. data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/other-index.html +1 -0
  474. data/vendor/rails/actionpack/test/journey/gtg/builder_test.rb +81 -0
  475. data/vendor/rails/actionpack/test/journey/gtg/transition_table_test.rb +125 -0
  476. data/vendor/rails/actionpack/test/journey/nfa/simulator_test.rb +100 -0
  477. data/vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb +74 -0
  478. data/vendor/rails/actionpack/test/journey/nodes/symbol_test.rb +19 -0
  479. data/vendor/rails/actionpack/test/journey/path/pattern_test.rb +286 -0
  480. data/vendor/rails/actionpack/test/journey/route/definition/parser_test.rb +112 -0
  481. data/vendor/rails/actionpack/test/journey/route/definition/scanner_test.rb +71 -0
  482. data/vendor/rails/actionpack/test/journey/route_test.rb +113 -0
  483. data/vendor/rails/actionpack/test/journey/router/utils_test.rb +48 -0
  484. data/vendor/rails/actionpack/test/journey/router_test.rb +544 -0
  485. data/vendor/rails/actionpack/test/journey/routes_test.rb +62 -0
  486. data/vendor/rails/actionpack/test/lib/controller/fake_controllers.rb +37 -0
  487. data/vendor/rails/actionpack/test/lib/controller/fake_models.rb +79 -0
  488. data/vendor/rails/actionpack/test/routing/helper_test.rb +33 -0
  489. data/vendor/rails/actionview/CHANGELOG.md +122 -0
  490. data/vendor/rails/actionview/MIT-LICENSE +21 -0
  491. data/vendor/rails/actionview/README.rdoc +38 -0
  492. data/vendor/rails/actionview/RUNNING_UJS_TESTS.rdoc +8 -0
  493. data/vendor/rails/actionview/RUNNING_UNIT_TESTS.rdoc +26 -0
  494. data/vendor/rails/actionview/Rakefile +136 -0
  495. data/vendor/rails/actionview/actionview.gemspec +38 -0
  496. data/vendor/rails/actionview/app/assets/javascripts/MIT-LICENSE +20 -0
  497. data/vendor/rails/actionview/app/assets/javascripts/README.md +55 -0
  498. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs.coffee +39 -0
  499. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/BANNER.js +5 -0
  500. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee +26 -0
  501. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee +82 -0
  502. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/method.coffee +34 -0
  503. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee +90 -0
  504. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/start.coffee +71 -0
  505. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee +97 -0
  506. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/csp.coffee +4 -0
  507. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/csrf.coffee +25 -0
  508. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/dom.coffee +35 -0
  509. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee +68 -0
  510. data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee +36 -0
  511. data/vendor/rails/actionview/bin/test +5 -0
  512. data/vendor/rails/actionview/blade.yml +11 -0
  513. data/vendor/rails/actionview/coffeelint.json +135 -0
  514. data/vendor/rails/actionview/lib/action_view.rb +97 -0
  515. data/vendor/rails/actionview/lib/action_view/base.rb +215 -0
  516. data/vendor/rails/actionview/lib/action_view/buffers.rb +52 -0
  517. data/vendor/rails/actionview/lib/action_view/context.rb +36 -0
  518. data/vendor/rails/actionview/lib/action_view/dependency_tracker.rb +175 -0
  519. data/vendor/rails/actionview/lib/action_view/digestor.rb +136 -0
  520. data/vendor/rails/actionview/lib/action_view/flows.rb +76 -0
  521. data/vendor/rails/actionview/lib/action_view/gem_version.rb +17 -0
  522. data/vendor/rails/actionview/lib/action_view/helpers.rb +68 -0
  523. data/vendor/rails/actionview/lib/action_view/helpers/active_model_helper.rb +55 -0
  524. data/vendor/rails/actionview/lib/action_view/helpers/asset_tag_helper.rb +511 -0
  525. data/vendor/rails/actionview/lib/action_view/helpers/asset_url_helper.rb +469 -0
  526. data/vendor/rails/actionview/lib/action_view/helpers/atom_feed_helper.rb +205 -0
  527. data/vendor/rails/actionview/lib/action_view/helpers/cache_helper.rb +263 -0
  528. data/vendor/rails/actionview/lib/action_view/helpers/capture_helper.rb +212 -0
  529. data/vendor/rails/actionview/lib/action_view/helpers/controller_helper.rb +36 -0
  530. data/vendor/rails/actionview/lib/action_view/helpers/csp_helper.rb +24 -0
  531. data/vendor/rails/actionview/lib/action_view/helpers/csrf_helper.rb +35 -0
  532. data/vendor/rails/actionview/lib/action_view/helpers/date_helper.rb +1156 -0
  533. data/vendor/rails/actionview/lib/action_view/helpers/debug_helper.rb +36 -0
  534. data/vendor/rails/actionview/lib/action_view/helpers/form_helper.rb +2337 -0
  535. data/vendor/rails/actionview/lib/action_view/helpers/form_options_helper.rb +887 -0
  536. data/vendor/rails/actionview/lib/action_view/helpers/form_tag_helper.rb +917 -0
  537. data/vendor/rails/actionview/lib/action_view/helpers/javascript_helper.rb +94 -0
  538. data/vendor/rails/actionview/lib/action_view/helpers/number_helper.rb +451 -0
  539. data/vendor/rails/actionview/lib/action_view/helpers/output_safety_helper.rb +70 -0
  540. data/vendor/rails/actionview/lib/action_view/helpers/record_tag_helper.rb +23 -0
  541. data/vendor/rails/actionview/lib/action_view/helpers/rendering_helper.rb +99 -0
  542. data/vendor/rails/actionview/lib/action_view/helpers/sanitize_helper.rb +177 -0
  543. data/vendor/rails/actionview/lib/action_view/helpers/tag_helper.rb +313 -0
  544. data/vendor/rails/actionview/lib/action_view/helpers/tags.rb +44 -0
  545. data/vendor/rails/actionview/lib/action_view/helpers/tags/base.rb +192 -0
  546. data/vendor/rails/actionview/lib/action_view/helpers/tags/check_box.rb +66 -0
  547. data/vendor/rails/actionview/lib/action_view/helpers/tags/checkable.rb +18 -0
  548. data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +36 -0
  549. data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_helpers.rb +119 -0
  550. data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +31 -0
  551. data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_select.rb +30 -0
  552. data/vendor/rails/actionview/lib/action_view/helpers/tags/color_field.rb +27 -0
  553. data/vendor/rails/actionview/lib/action_view/helpers/tags/date_field.rb +15 -0
  554. data/vendor/rails/actionview/lib/action_view/helpers/tags/date_select.rb +74 -0
  555. data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb +32 -0
  556. data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_local_field.rb +21 -0
  557. data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_select.rb +10 -0
  558. data/vendor/rails/actionview/lib/action_view/helpers/tags/email_field.rb +10 -0
  559. data/vendor/rails/actionview/lib/action_view/helpers/tags/file_field.rb +10 -0
  560. data/vendor/rails/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb +31 -0
  561. data/vendor/rails/actionview/lib/action_view/helpers/tags/hidden_field.rb +10 -0
  562. data/vendor/rails/actionview/lib/action_view/helpers/tags/label.rb +81 -0
  563. data/vendor/rails/actionview/lib/action_view/helpers/tags/month_field.rb +15 -0
  564. data/vendor/rails/actionview/lib/action_view/helpers/tags/number_field.rb +20 -0
  565. data/vendor/rails/actionview/lib/action_view/helpers/tags/password_field.rb +14 -0
  566. data/vendor/rails/actionview/lib/action_view/helpers/tags/placeholderable.rb +24 -0
  567. data/vendor/rails/actionview/lib/action_view/helpers/tags/radio_button.rb +33 -0
  568. data/vendor/rails/actionview/lib/action_view/helpers/tags/range_field.rb +10 -0
  569. data/vendor/rails/actionview/lib/action_view/helpers/tags/search_field.rb +27 -0
  570. data/vendor/rails/actionview/lib/action_view/helpers/tags/select.rb +43 -0
  571. data/vendor/rails/actionview/lib/action_view/helpers/tags/tel_field.rb +10 -0
  572. data/vendor/rails/actionview/lib/action_view/helpers/tags/text_area.rb +24 -0
  573. data/vendor/rails/actionview/lib/action_view/helpers/tags/text_field.rb +34 -0
  574. data/vendor/rails/actionview/lib/action_view/helpers/tags/time_field.rb +15 -0
  575. data/vendor/rails/actionview/lib/action_view/helpers/tags/time_select.rb +10 -0
  576. data/vendor/rails/actionview/lib/action_view/helpers/tags/time_zone_select.rb +22 -0
  577. data/vendor/rails/actionview/lib/action_view/helpers/tags/translator.rb +44 -0
  578. data/vendor/rails/actionview/lib/action_view/helpers/tags/url_field.rb +10 -0
  579. data/vendor/rails/actionview/lib/action_view/helpers/tags/week_field.rb +15 -0
  580. data/vendor/rails/actionview/lib/action_view/helpers/text_helper.rb +486 -0
  581. data/vendor/rails/actionview/lib/action_view/helpers/translation_helper.rb +141 -0
  582. data/vendor/rails/actionview/lib/action_view/helpers/url_helper.rb +676 -0
  583. data/vendor/rails/actionview/lib/action_view/layouts.rb +433 -0
  584. data/vendor/rails/actionview/lib/action_view/locale/en.yml +56 -0
  585. data/vendor/rails/actionview/lib/action_view/log_subscriber.rb +96 -0
  586. data/vendor/rails/actionview/lib/action_view/lookup_context.rb +274 -0
  587. data/vendor/rails/actionview/lib/action_view/model_naming.rb +14 -0
  588. data/vendor/rails/actionview/lib/action_view/path_set.rb +100 -0
  589. data/vendor/rails/actionview/lib/action_view/railtie.rb +82 -0
  590. data/vendor/rails/actionview/lib/action_view/record_identifier.rb +112 -0
  591. data/vendor/rails/actionview/lib/action_view/renderer/abstract_renderer.rb +55 -0
  592. data/vendor/rails/actionview/lib/action_view/renderer/partial_renderer.rb +552 -0
  593. data/vendor/rails/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb +57 -0
  594. data/vendor/rails/actionview/lib/action_view/renderer/renderer.rb +56 -0
  595. data/vendor/rails/actionview/lib/action_view/renderer/streaming_template_renderer.rb +105 -0
  596. data/vendor/rails/actionview/lib/action_view/renderer/template_renderer.rb +102 -0
  597. data/vendor/rails/actionview/lib/action_view/rendering.rb +151 -0
  598. data/vendor/rails/actionview/lib/action_view/routing_url_for.rb +145 -0
  599. data/vendor/rails/actionview/lib/action_view/tasks/cache_digests.rake +25 -0
  600. data/vendor/rails/actionview/lib/action_view/template.rb +361 -0
  601. data/vendor/rails/actionview/lib/action_view/template/error.rb +141 -0
  602. data/vendor/rails/actionview/lib/action_view/template/handlers.rb +66 -0
  603. data/vendor/rails/actionview/lib/action_view/template/handlers/builder.rb +25 -0
  604. data/vendor/rails/actionview/lib/action_view/template/handlers/erb.rb +74 -0
  605. data/vendor/rails/actionview/lib/action_view/template/handlers/erb/erubi.rb +83 -0
  606. data/vendor/rails/actionview/lib/action_view/template/handlers/html.rb +11 -0
  607. data/vendor/rails/actionview/lib/action_view/template/handlers/raw.rb +11 -0
  608. data/vendor/rails/actionview/lib/action_view/template/html.rb +34 -0
  609. data/vendor/rails/actionview/lib/action_view/template/resolver.rb +391 -0
  610. data/vendor/rails/actionview/lib/action_view/template/text.rb +33 -0
  611. data/vendor/rails/actionview/lib/action_view/template/types.rb +57 -0
  612. data/vendor/rails/actionview/lib/action_view/test_case.rb +300 -0
  613. data/vendor/rails/actionview/lib/action_view/testing/resolvers.rb +54 -0
  614. data/vendor/rails/actionview/lib/action_view/version.rb +10 -0
  615. data/vendor/rails/actionview/lib/action_view/view_paths.rb +105 -0
  616. data/vendor/rails/actionview/package.json +36 -0
  617. data/vendor/rails/actionview/test/abstract_unit.rb +236 -0
  618. data/vendor/rails/actionview/test/actionpack/abstract/abstract_controller_test.rb +292 -0
  619. data/vendor/rails/actionview/test/actionpack/abstract/helper_test.rb +128 -0
  620. data/vendor/rails/actionview/test/actionpack/abstract/layouts_test.rb +568 -0
  621. data/vendor/rails/actionview/test/actionpack/abstract/render_test.rb +103 -0
  622. data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/formatted.html.erb +1 -0
  623. data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/index.erb +1 -0
  624. data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me4/index.erb +1 -0
  625. data/vendor/rails/actionview/test/actionpack/abstract/views/action_with_ivars.erb +1 -0
  626. data/vendor/rails/actionview/test/actionpack/abstract/views/helper_test.erb +1 -0
  627. data/vendor/rails/actionview/test/actionpack/abstract/views/index.erb +1 -0
  628. data/vendor/rails/actionview/test/actionpack/abstract/views/layouts/abstract_controller/testing/me4.erb +1 -0
  629. data/vendor/rails/actionview/test/actionpack/abstract/views/layouts/application.erb +1 -0
  630. data/vendor/rails/actionview/test/actionpack/abstract/views/naked_render.erb +1 -0
  631. data/vendor/rails/actionview/test/actionpack/controller/capture_test.rb +83 -0
  632. data/vendor/rails/actionview/test/actionpack/controller/layout_test.rb +270 -0
  633. data/vendor/rails/actionview/test/actionpack/controller/render_test.rb +1294 -0
  634. data/vendor/rails/actionview/test/actionpack/controller/view_paths_test.rb +174 -0
  635. data/vendor/rails/actionview/test/active_record_unit.rb +92 -0
  636. data/vendor/rails/actionview/test/activerecord/controller_runtime_test.rb +95 -0
  637. data/vendor/rails/actionview/test/activerecord/debug_helper_test.rb +19 -0
  638. data/vendor/rails/actionview/test/activerecord/form_helper_activerecord_test.rb +90 -0
  639. data/vendor/rails/actionview/test/activerecord/polymorphic_routes_test.rb +780 -0
  640. data/vendor/rails/actionview/test/activerecord/relation_cache_test.rb +23 -0
  641. data/vendor/rails/actionview/test/activerecord/render_partial_with_record_identification_test.rb +188 -0
  642. data/vendor/rails/actionview/test/fixtures/_top_level_partial.html.erb +1 -0
  643. data/vendor/rails/actionview/test/fixtures/_top_level_partial_only.erb +1 -0
  644. data/vendor/rails/actionview/test/fixtures/actionpack/bad_customers/_bad_customer.html.erb +1 -0
  645. data/vendor/rails/actionview/test/fixtures/actionpack/customers/_customer.html.erb +1 -0
  646. data/vendor/rails/actionview/test/fixtures/actionpack/fun/games/_form.erb +1 -0
  647. data/vendor/rails/actionview/test/fixtures/actionpack/fun/games/hello_world.erb +1 -0
  648. data/vendor/rails/actionview/test/fixtures/actionpack/good_customers/_good_customer.html.erb +1 -0
  649. data/vendor/rails/actionview/test/fixtures/actionpack/hello.html +1 -0
  650. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/alt/layouts/alt.erb +1 -0
  651. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/controller_name_space/nested.erb +1 -0
  652. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/item.erb +1 -0
  653. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/layout_test.erb +1 -0
  654. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/multiple_extensions.html.erb +1 -0
  655. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/symlinked/symlinked_layout.erb +5 -0
  656. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/third_party_template_library.mab +1 -0
  657. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/views/goodbye.erb +1 -0
  658. data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/views/hello.erb +1 -0
  659. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_column.html.erb +2 -0
  660. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_customers.erb +1 -0
  661. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_partial_and_yield.erb +2 -0
  662. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_yield_only.erb +1 -0
  663. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_yield_with_params.erb +1 -0
  664. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/block_with_layout.erb +3 -0
  665. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/builder.builder +3 -0
  666. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/partial_with_layout.erb +3 -0
  667. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/standard.html.erb +1 -0
  668. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/standard.text.erb +1 -0
  669. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/streaming.erb +4 -0
  670. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/talk_from_action.erb +2 -0
  671. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/with_html_partial.html.erb +1 -0
  672. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/xhr.html.erb +2 -0
  673. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield.erb +2 -0
  674. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield_with_render_inline_inside.erb +2 -0
  675. data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield_with_render_partial_inside.erb +2 -0
  676. data/vendor/rails/actionview/test/fixtures/actionpack/quiz/questions/_question.html.erb +1 -0
  677. data/vendor/rails/actionview/test/fixtures/actionpack/shared.html.erb +1 -0
  678. data/vendor/rails/actionview/test/fixtures/actionpack/test/_changing_priority.html.erb +1 -0
  679. data/vendor/rails/actionview/test/fixtures/actionpack/test/_changing_priority.json.erb +1 -0
  680. data/vendor/rails/actionview/test/fixtures/actionpack/test/_counter.html.erb +1 -0
  681. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer.erb +1 -0
  682. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_counter.erb +1 -0
  683. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_counter_with_as.erb +1 -0
  684. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_greeting.erb +1 -0
  685. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_iteration.erb +1 -0
  686. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_iteration_with_as.erb +1 -0
  687. data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_with_var.erb +1 -0
  688. data/vendor/rails/actionview/test/fixtures/actionpack/test/_directory/_partial_with_locales.html.erb +1 -0
  689. data/vendor/rails/actionview/test/fixtures/actionpack/test/_first_json_partial.json.erb +1 -0
  690. data/vendor/rails/actionview/test/fixtures/actionpack/test/_form.erb +1 -0
  691. data/vendor/rails/actionview/test/fixtures/actionpack/test/_hash_greeting.erb +1 -0
  692. data/vendor/rails/actionview/test/fixtures/actionpack/test/_hash_object.erb +2 -0
  693. data/vendor/rails/actionview/test/fixtures/actionpack/test/_hello.builder +1 -0
  694. data/vendor/rails/actionview/test/fixtures/actionpack/test/_json_change_priority.json.erb +0 -0
  695. data/vendor/rails/actionview/test/fixtures/actionpack/test/_labelling_form.erb +1 -0
  696. data/vendor/rails/actionview/test/fixtures/actionpack/test/_layout_for_partial.html.erb +3 -0
  697. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.erb +1 -0
  698. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.html.erb +1 -0
  699. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.js.erb +1 -0
  700. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_for_use_in_layout.html.erb +1 -0
  701. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_html_erb.html.erb +1 -0
  702. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_name_local_variable.erb +1 -0
  703. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_only.erb +1 -0
  704. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_only_html.html +1 -0
  705. data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_with_partial.erb +2 -0
  706. data/vendor/rails/actionview/test/fixtures/actionpack/test/_person.erb +2 -0
  707. data/vendor/rails/actionview/test/fixtures/actionpack/test/_raise_indentation.html.erb +13 -0
  708. data/vendor/rails/actionview/test/fixtures/actionpack/test/_second_json_partial.json.erb +1 -0
  709. data/vendor/rails/actionview/test/fixtures/actionpack/test/action_talk_to_layout.erb +2 -0
  710. data/vendor/rails/actionview/test/fixtures/actionpack/test/calling_partial_with_layout.html.erb +1 -0
  711. data/vendor/rails/actionview/test/fixtures/actionpack/test/capturing.erb +4 -0
  712. data/vendor/rails/actionview/test/fixtures/actionpack/test/change_priority.html.erb +2 -0
  713. data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for.erb +1 -0
  714. data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for_concatenated.erb +3 -0
  715. data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for_with_parameter.erb +2 -0
  716. data/vendor/rails/actionview/test/fixtures/actionpack/test/dot.directory/render_file_with_ivar.erb +1 -0
  717. data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_html_erb.html.erb +1 -0
  718. data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.builder +1 -0
  719. data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.html.erb +1 -0
  720. data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.xml.erb +1 -0
  721. data/vendor/rails/actionview/test/fixtures/actionpack/test/greeting.html.erb +1 -0
  722. data/vendor/rails/actionview/test/fixtures/actionpack/test/greeting.xml.erb +1 -0
  723. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello,world.erb +1 -0
  724. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello.builder +4 -0
  725. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello/hello.erb +1 -0
  726. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world.erb +1 -0
  727. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_container.builder +3 -0
  728. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_from_rxml.builder +3 -0
  729. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_with_layout_false.erb +1 -0
  730. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_with_partial.html.erb +2 -0
  731. data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_xml_world.builder +11 -0
  732. data/vendor/rails/actionview/test/fixtures/actionpack/test/html_template.html.erb +1 -0
  733. data/vendor/rails/actionview/test/fixtures/actionpack/test/hyphen-ated.erb +1 -0
  734. data/vendor/rails/actionview/test/fixtures/actionpack/test/implicit_content_type.atom.builder +2 -0
  735. data/vendor/rails/actionview/test/fixtures/actionpack/test/list.erb +1 -0
  736. data/vendor/rails/actionview/test/fixtures/actionpack/test/non_erb_block_content_for.builder +4 -0
  737. data/vendor/rails/actionview/test/fixtures/actionpack/test/potential_conflicts.erb +4 -0
  738. data/vendor/rails/actionview/test/fixtures/actionpack/test/proper_block_detection.erb +1 -0
  739. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_from_template.html.erb +1 -0
  740. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_ivar.erb +1 -0
  741. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_locals.erb +1 -0
  742. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_locals_and_default.erb +1 -0
  743. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
  744. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
  745. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_js_template_without_layout.js.erb +1 -0
  746. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_partial_inside_directory.html.erb +1 -0
  747. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_to_string_test.erb +1 -0
  748. data/vendor/rails/actionview/test/fixtures/actionpack/test/render_two_partials.html.erb +2 -0
  749. data/vendor/rails/actionview/test/fixtures/actionpack/test/using_layout_around_block.html.erb +1 -0
  750. data/vendor/rails/actionview/test/fixtures/actionpack/test/with_html_partial.html.erb +1 -0
  751. data/vendor/rails/actionview/test/fixtures/actionpack/test/with_partial.html.erb +1 -0
  752. data/vendor/rails/actionview/test/fixtures/actionpack/test/with_partial.text.erb +1 -0
  753. data/vendor/rails/actionview/test/fixtures/actionpack/test/with_xml_template.html.erb +1 -0
  754. data/vendor/rails/actionview/test/fixtures/comments/empty.de.html.erb +1 -0
  755. data/vendor/rails/actionview/test/fixtures/comments/empty.html+grid.erb +1 -0
  756. data/vendor/rails/actionview/test/fixtures/comments/empty.html.builder +1 -0
  757. data/vendor/rails/actionview/test/fixtures/comments/empty.html.erb +1 -0
  758. data/vendor/rails/actionview/test/fixtures/comments/empty.xml.erb +1 -0
  759. data/vendor/rails/actionview/test/fixtures/companies.yml +24 -0
  760. data/vendor/rails/actionview/test/fixtures/company.rb +11 -0
  761. data/vendor/rails/actionview/test/fixtures/custom_pattern/another.html.erb +1 -0
  762. data/vendor/rails/actionview/test/fixtures/custom_pattern/html/another.erb +1 -0
  763. data/vendor/rails/actionview/test/fixtures/custom_pattern/html/path.erb +1 -0
  764. data/vendor/rails/actionview/test/fixtures/customers/_customer.html.erb +1 -0
  765. data/vendor/rails/actionview/test/fixtures/customers/_customer.xml.erb +1 -0
  766. data/vendor/rails/actionview/test/fixtures/db_definitions/sqlite.sql +49 -0
  767. data/vendor/rails/actionview/test/fixtures/developer.rb +8 -0
  768. data/vendor/rails/actionview/test/fixtures/developers.yml +21 -0
  769. data/vendor/rails/actionview/test/fixtures/developers/_developer.erb +1 -0
  770. data/vendor/rails/actionview/test/fixtures/developers_projects.yml +13 -0
  771. data/vendor/rails/actionview/test/fixtures/digestor/api/comments/_comment.json.erb +1 -0
  772. data/vendor/rails/actionview/test/fixtures/digestor/api/comments/_comments.json.erb +1 -0
  773. data/vendor/rails/actionview/test/fixtures/digestor/comments/_comment.html.erb +1 -0
  774. data/vendor/rails/actionview/test/fixtures/digestor/comments/_comments.html.erb +1 -0
  775. data/vendor/rails/actionview/test/fixtures/digestor/comments/show.js.erb +1 -0
  776. data/vendor/rails/actionview/test/fixtures/digestor/events/_completed.html.erb +0 -0
  777. data/vendor/rails/actionview/test/fixtures/digestor/events/_event.html.erb +0 -0
  778. data/vendor/rails/actionview/test/fixtures/digestor/events/index.html.erb +1 -0
  779. data/vendor/rails/actionview/test/fixtures/digestor/level/_recursion.html.erb +1 -0
  780. data/vendor/rails/actionview/test/fixtures/digestor/level/below/_header.html.erb +0 -0
  781. data/vendor/rails/actionview/test/fixtures/digestor/level/below/index.html.erb +1 -0
  782. data/vendor/rails/actionview/test/fixtures/digestor/level/recursion.html.erb +1 -0
  783. data/vendor/rails/actionview/test/fixtures/digestor/messages/_form.html.erb +0 -0
  784. data/vendor/rails/actionview/test/fixtures/digestor/messages/_header.html.erb +0 -0
  785. data/vendor/rails/actionview/test/fixtures/digestor/messages/_message.html.erb +1 -0
  786. data/vendor/rails/actionview/test/fixtures/digestor/messages/actions/_move.html.erb +0 -0
  787. data/vendor/rails/actionview/test/fixtures/digestor/messages/edit.html.erb +5 -0
  788. data/vendor/rails/actionview/test/fixtures/digestor/messages/index.html.erb +2 -0
  789. data/vendor/rails/actionview/test/fixtures/digestor/messages/new.html+iphone.erb +15 -0
  790. data/vendor/rails/actionview/test/fixtures/digestor/messages/peek.html.erb +2 -0
  791. data/vendor/rails/actionview/test/fixtures/digestor/messages/show.html.erb +14 -0
  792. data/vendor/rails/actionview/test/fixtures/digestor/messages/thread.json.erb +1 -0
  793. data/vendor/rails/actionview/test/fixtures/fun/games/_game.erb +1 -0
  794. data/vendor/rails/actionview/test/fixtures/fun/games/hello_world.erb +1 -0
  795. data/vendor/rails/actionview/test/fixtures/fun/serious/games/_game.erb +1 -0
  796. data/vendor/rails/actionview/test/fixtures/games/_game.erb +1 -0
  797. data/vendor/rails/actionview/test/fixtures/good_customers/_good_customer.html.erb +1 -0
  798. data/vendor/rails/actionview/test/fixtures/helpers/abc_helper.rb +5 -0
  799. data/vendor/rails/actionview/test/fixtures/helpers/helpery_test_helper.rb +7 -0
  800. data/vendor/rails/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb +6 -0
  801. data/vendor/rails/actionview/test/fixtures/layout_tests/alt/hello.erb +1 -0
  802. data/vendor/rails/actionview/test/fixtures/layouts/_column.html.erb +2 -0
  803. data/vendor/rails/actionview/test/fixtures/layouts/_customers.erb +1 -0
  804. data/vendor/rails/actionview/test/fixtures/layouts/_partial_and_yield.erb +2 -0
  805. data/vendor/rails/actionview/test/fixtures/layouts/_yield_only.erb +1 -0
  806. data/vendor/rails/actionview/test/fixtures/layouts/_yield_with_params.erb +1 -0
  807. data/vendor/rails/actionview/test/fixtures/layouts/render_partial_html.erb +2 -0
  808. data/vendor/rails/actionview/test/fixtures/layouts/streaming.erb +4 -0
  809. data/vendor/rails/actionview/test/fixtures/layouts/streaming_with_capture.erb +6 -0
  810. data/vendor/rails/actionview/test/fixtures/layouts/streaming_with_locale.erb +2 -0
  811. data/vendor/rails/actionview/test/fixtures/layouts/yield.erb +2 -0
  812. data/vendor/rails/actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb +2 -0
  813. data/vendor/rails/actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb +2 -0
  814. data/vendor/rails/actionview/test/fixtures/mascot.rb +5 -0
  815. data/vendor/rails/actionview/test/fixtures/mascots.yml +4 -0
  816. data/vendor/rails/actionview/test/fixtures/mascots/_mascot.html.erb +1 -0
  817. data/vendor/rails/actionview/test/fixtures/override/test/hello_world.erb +1 -0
  818. data/vendor/rails/actionview/test/fixtures/override2/layouts/test/sub.erb +1 -0
  819. data/vendor/rails/actionview/test/fixtures/plain_text.raw +1 -0
  820. data/vendor/rails/actionview/test/fixtures/plain_text_with_characters.raw +1 -0
  821. data/vendor/rails/actionview/test/fixtures/project.rb +9 -0
  822. data/vendor/rails/actionview/test/fixtures/projects.yml +7 -0
  823. data/vendor/rails/actionview/test/fixtures/projects/_project.erb +1 -0
  824. data/vendor/rails/actionview/test/fixtures/public/elsewhere/cools.js +1 -0
  825. data/vendor/rails/actionview/test/fixtures/public/elsewhere/file.css +1 -0
  826. data/vendor/rails/actionview/test/fixtures/public/foo/baz.css +3 -0
  827. data/vendor/rails/actionview/test/fixtures/public/javascripts/application.js +1 -0
  828. data/vendor/rails/actionview/test/fixtures/public/javascripts/bank.js +1 -0
  829. data/vendor/rails/actionview/test/fixtures/public/javascripts/common.javascript +1 -0
  830. data/vendor/rails/actionview/test/fixtures/public/javascripts/controls.js +1 -0
  831. data/vendor/rails/actionview/test/fixtures/public/javascripts/dragdrop.js +1 -0
  832. data/vendor/rails/actionview/test/fixtures/public/javascripts/effects.js +1 -0
  833. data/vendor/rails/actionview/test/fixtures/public/javascripts/prototype.js +1 -0
  834. data/vendor/rails/actionview/test/fixtures/public/javascripts/robber.js +1 -0
  835. data/vendor/rails/actionview/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
  836. data/vendor/rails/actionview/test/fixtures/public/javascripts/version.1.0.js +1 -0
  837. data/vendor/rails/actionview/test/fixtures/public/stylesheets/bank.css +1 -0
  838. data/vendor/rails/actionview/test/fixtures/public/stylesheets/random.styles +1 -0
  839. data/vendor/rails/actionview/test/fixtures/public/stylesheets/robber.css +1 -0
  840. data/vendor/rails/actionview/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
  841. data/vendor/rails/actionview/test/fixtures/public/stylesheets/version.1.0.css +1 -0
  842. data/vendor/rails/actionview/test/fixtures/replies.yml +15 -0
  843. data/vendor/rails/actionview/test/fixtures/replies/_reply.erb +1 -0
  844. data/vendor/rails/actionview/test/fixtures/reply.rb +9 -0
  845. data/vendor/rails/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
  846. data/vendor/rails/actionview/test/fixtures/ruby_template.ruby +2 -0
  847. data/vendor/rails/actionview/test/fixtures/shared.html.erb +1 -0
  848. data/vendor/rails/actionview/test/fixtures/test/_200.html.erb +1 -0
  849. data/vendor/rails/actionview/test/fixtures/test/_FooBar.html.erb +1 -0
  850. data/vendor/rails/actionview/test/fixtures/test/_a-in.html.erb +0 -0
  851. data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial.html.erb +1 -0
  852. data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb +1 -0
  853. data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb +1 -0
  854. data/vendor/rails/actionview/test/fixtures/test/_builder_tag_nested_in_content_tag.erb +3 -0
  855. data/vendor/rails/actionview/test/fixtures/test/_cached_customer.erb +3 -0
  856. data/vendor/rails/actionview/test/fixtures/test/_cached_customer_as.erb +3 -0
  857. data/vendor/rails/actionview/test/fixtures/test/_cached_nested_cached_customer.erb +3 -0
  858. data/vendor/rails/actionview/test/fixtures/test/_changing_priority.html.erb +1 -0
  859. data/vendor/rails/actionview/test/fixtures/test/_changing_priority.json.erb +1 -0
  860. data/vendor/rails/actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb +3 -0
  861. data/vendor/rails/actionview/test/fixtures/test/_counter.html.erb +1 -0
  862. data/vendor/rails/actionview/test/fixtures/test/_customer.erb +1 -0
  863. data/vendor/rails/actionview/test/fixtures/test/_customer.mobile.erb +1 -0
  864. data/vendor/rails/actionview/test/fixtures/test/_customer_greeting.erb +1 -0
  865. data/vendor/rails/actionview/test/fixtures/test/_customer_with_var.erb +1 -0
  866. data/vendor/rails/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb +1 -0
  867. data/vendor/rails/actionview/test/fixtures/test/_first_json_partial.json.erb +1 -0
  868. data/vendor/rails/actionview/test/fixtures/test/_from_helper.erb +1 -0
  869. data/vendor/rails/actionview/test/fixtures/test/_json_change_priority.json.erb +0 -0
  870. data/vendor/rails/actionview/test/fixtures/test/_klass.erb +1 -0
  871. data/vendor/rails/actionview/test/fixtures/test/_label_with_block.erb +4 -0
  872. data/vendor/rails/actionview/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
  873. data/vendor/rails/actionview/test/fixtures/test/_layout_for_partial.html.erb +3 -0
  874. data/vendor/rails/actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb +4 -0
  875. data/vendor/rails/actionview/test/fixtures/test/_local_inspector.html.erb +1 -0
  876. data/vendor/rails/actionview/test/fixtures/test/_nested_cached_customer.erb +1 -0
  877. data/vendor/rails/actionview/test/fixtures/test/_object_inspector.erb +1 -0
  878. data/vendor/rails/actionview/test/fixtures/test/_one.html.erb +1 -0
  879. data/vendor/rails/actionview/test/fixtures/test/_partial.erb +1 -0
  880. data/vendor/rails/actionview/test/fixtures/test/_partial.html.erb +1 -0
  881. data/vendor/rails/actionview/test/fixtures/test/_partial.js.erb +1 -0
  882. data/vendor/rails/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
  883. data/vendor/rails/actionview/test/fixtures/test/_partial_iteration_1.erb +1 -0
  884. data/vendor/rails/actionview/test/fixtures/test/_partial_iteration_2.erb +1 -0
  885. data/vendor/rails/actionview/test/fixtures/test/_partial_name_in_local_assigns.erb +1 -0
  886. data/vendor/rails/actionview/test/fixtures/test/_partial_name_local_variable.erb +1 -0
  887. data/vendor/rails/actionview/test/fixtures/test/_partial_only.erb +1 -0
  888. data/vendor/rails/actionview/test/fixtures/test/_partial_shortcut_with_block_content.html.erb +3 -0
  889. data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout.erb +2 -0
  890. data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout_block_content.erb +4 -0
  891. data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout_block_partial.erb +4 -0
  892. data/vendor/rails/actionview/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
  893. data/vendor/rails/actionview/test/fixtures/test/_partial_with_partial.erb +2 -0
  894. data/vendor/rails/actionview/test/fixtures/test/_partial_with_variants.html+grid.erb +1 -0
  895. data/vendor/rails/actionview/test/fixtures/test/_partialhtml.html +1 -0
  896. data/vendor/rails/actionview/test/fixtures/test/_raise.html.erb +1 -0
  897. data/vendor/rails/actionview/test/fixtures/test/_raise_indentation.html.erb +13 -0
  898. data/vendor/rails/actionview/test/fixtures/test/_second_json_partial.json.erb +1 -0
  899. data/vendor/rails/actionview/test/fixtures/test/_two.html.erb +1 -0
  900. data/vendor/rails/actionview/test/fixtures/test/_utf8_partial.html.erb +1 -0
  901. data/vendor/rails/actionview/test/fixtures/test/_utf8_partial_magic.html.erb +2 -0
  902. data/vendor/rails/actionview/test/fixtures/test/_/360/237/215/243.erb +1 -0
  903. data/vendor/rails/actionview/test/fixtures/test/basic.html.erb +1 -0
  904. data/vendor/rails/actionview/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
  905. data/vendor/rails/actionview/test/fixtures/test/change_priority.html.erb +2 -0
  906. data/vendor/rails/actionview/test/fixtures/test/dont_pick_me +1 -0
  907. data/vendor/rails/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
  908. data/vendor/rails/actionview/test/fixtures/test/greeting.xml.erb +1 -0
  909. data/vendor/rails/actionview/test/fixtures/test/hello.builder +4 -0
  910. data/vendor/rails/actionview/test/fixtures/test/hello/hello.erb +1 -0
  911. data/vendor/rails/actionview/test/fixtures/test/hello_world.da.html.erb +1 -0
  912. data/vendor/rails/actionview/test/fixtures/test/hello_world.erb +1 -0
  913. data/vendor/rails/actionview/test/fixtures/test/hello_world.erb~ +1 -0
  914. data/vendor/rails/actionview/test/fixtures/test/hello_world.html+phone.erb +1 -0
  915. data/vendor/rails/actionview/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
  916. data/vendor/rails/actionview/test/fixtures/test/hello_world.text+phone.erb +1 -0
  917. data/vendor/rails/actionview/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
  918. data/vendor/rails/actionview/test/fixtures/test/html_template.html.erb +1 -0
  919. data/vendor/rails/actionview/test/fixtures/test/layout_render_file.erb +2 -0
  920. data/vendor/rails/actionview/test/fixtures/test/layout_render_object.erb +1 -0
  921. data/vendor/rails/actionview/test/fixtures/test/list.erb +1 -0
  922. data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
  923. data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.erb~ +1 -0
  924. data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
  925. data/vendor/rails/actionview/test/fixtures/test/malformed/malformed~ +1 -0
  926. data/vendor/rails/actionview/test/fixtures/test/nested_layout.erb +3 -0
  927. data/vendor/rails/actionview/test/fixtures/test/nested_streaming.erb +3 -0
  928. data/vendor/rails/actionview/test/fixtures/test/nil_return.erb +1 -0
  929. data/vendor/rails/actionview/test/fixtures/test/one.html.erb +1 -0
  930. data/vendor/rails/actionview/test/fixtures/test/render_file_inspect_local_assigns.erb +1 -0
  931. data/vendor/rails/actionview/test/fixtures/test/render_file_instance_variable.erb +1 -0
  932. data/vendor/rails/actionview/test/fixtures/test/render_file_unicode_local.erb +1 -0
  933. data/vendor/rails/actionview/test/fixtures/test/render_file_with_ivar.erb +1 -0
  934. data/vendor/rails/actionview/test/fixtures/test/render_file_with_locals.erb +1 -0
  935. data/vendor/rails/actionview/test/fixtures/test/render_file_with_locals_and_default.erb +1 -0
  936. data/vendor/rails/actionview/test/fixtures/test/render_file_with_ruby_keyword_locals.erb +1 -0
  937. data/vendor/rails/actionview/test/fixtures/test/render_partial_inside_directory.html.erb +1 -0
  938. data/vendor/rails/actionview/test/fixtures/test/render_two_partials.html.erb +2 -0
  939. data/vendor/rails/actionview/test/fixtures/test/streaming.erb +3 -0
  940. data/vendor/rails/actionview/test/fixtures/test/streaming_buster.erb +3 -0
  941. data/vendor/rails/actionview/test/fixtures/test/streaming_with_locale.erb +1 -0
  942. data/vendor/rails/actionview/test/fixtures/test/sub_template_raise.html.erb +1 -0
  943. data/vendor/rails/actionview/test/fixtures/test/template.erb +1 -0
  944. data/vendor/rails/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb +1 -0
  945. data/vendor/rails/actionview/test/fixtures/test/update_element_with_capture.erb +9 -0
  946. data/vendor/rails/actionview/test/fixtures/test/utf8.html.erb +4 -0
  947. data/vendor/rails/actionview/test/fixtures/test/utf8_magic.html.erb +5 -0
  948. data/vendor/rails/actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +5 -0
  949. data/vendor/rails/actionview/test/fixtures/topic.rb +5 -0
  950. data/vendor/rails/actionview/test/fixtures/topics.yml +22 -0
  951. data/vendor/rails/actionview/test/fixtures/topics/_topic.html.erb +1 -0
  952. data/vendor/rails/actionview/test/fixtures/translations/templates/array.erb +1 -0
  953. data/vendor/rails/actionview/test/fixtures/translations/templates/default.erb +1 -0
  954. data/vendor/rails/actionview/test/fixtures/translations/templates/found.erb +1 -0
  955. data/vendor/rails/actionview/test/fixtures/translations/templates/missing.erb +1 -0
  956. data/vendor/rails/actionview/test/fixtures/with_format.json.erb +1 -0
  957. data/vendor/rails/actionview/test/lib/controller/fake_models.rb +204 -0
  958. data/vendor/rails/actionview/test/template/active_model_helper_test.rb +172 -0
  959. data/vendor/rails/actionview/test/template/asset_tag_helper_test.rb +913 -0
  960. data/vendor/rails/actionview/test/template/atom_feed_helper_test.rb +375 -0
  961. data/vendor/rails/actionview/test/template/capture_helper_test.rb +228 -0
  962. data/vendor/rails/actionview/test/template/compiled_templates_test.rb +94 -0
  963. data/vendor/rails/actionview/test/template/controller_helper_test.rb +34 -0
  964. data/vendor/rails/actionview/test/template/date_helper_i18n_test.rb +166 -0
  965. data/vendor/rails/actionview/test/template/date_helper_test.rb +3642 -0
  966. data/vendor/rails/actionview/test/template/dependency_tracker_test.rb +195 -0
  967. data/vendor/rails/actionview/test/template/digestor_test.rb +389 -0
  968. data/vendor/rails/actionview/test/template/erb/form_for_test.rb +13 -0
  969. data/vendor/rails/actionview/test/template/erb/helper.rb +26 -0
  970. data/vendor/rails/actionview/test/template/erb/tag_helper_test.rb +32 -0
  971. data/vendor/rails/actionview/test/template/erb_util_test.rb +114 -0
  972. data/vendor/rails/actionview/test/template/form_collections_helper_test.rb +527 -0
  973. data/vendor/rails/actionview/test/template/form_helper/form_with_test.rb +2293 -0
  974. data/vendor/rails/actionview/test/template/form_helper_test.rb +3554 -0
  975. data/vendor/rails/actionview/test/template/form_options_helper_i18n_test.rb +30 -0
  976. data/vendor/rails/actionview/test/template/form_options_helper_test.rb +1452 -0
  977. data/vendor/rails/actionview/test/template/form_tag_helper_test.rb +785 -0
  978. data/vendor/rails/actionview/test/template/html_test.rb +19 -0
  979. data/vendor/rails/actionview/test/template/javascript_helper_test.rb +68 -0
  980. data/vendor/rails/actionview/test/template/log_subscriber_test.rb +224 -0
  981. data/vendor/rails/actionview/test/template/lookup_context_test.rb +289 -0
  982. data/vendor/rails/actionview/test/template/number_helper_test.rb +204 -0
  983. data/vendor/rails/actionview/test/template/output_safety_helper_test.rb +119 -0
  984. data/vendor/rails/actionview/test/template/partial_iteration_test.rb +35 -0
  985. data/vendor/rails/actionview/test/template/record_identifier_test.rb +93 -0
  986. data/vendor/rails/actionview/test/template/record_tag_helper_test.rb +33 -0
  987. data/vendor/rails/actionview/test/template/render_test.rb +725 -0
  988. data/vendor/rails/actionview/test/template/resolver_cache_test.rb +9 -0
  989. data/vendor/rails/actionview/test/template/resolver_patterns_test.rb +44 -0
  990. data/vendor/rails/actionview/test/template/sanitize_helper_test.rb +43 -0
  991. data/vendor/rails/actionview/test/template/streaming_render_test.rb +132 -0
  992. data/vendor/rails/actionview/test/template/tag_helper_test.rb +357 -0
  993. data/vendor/rails/actionview/test/template/template_error_test.rb +37 -0
  994. data/vendor/rails/actionview/test/template/template_test.rb +207 -0
  995. data/vendor/rails/actionview/test/template/test_case_test.rb +335 -0
  996. data/vendor/rails/actionview/test/template/test_test.rb +94 -0
  997. data/vendor/rails/actionview/test/template/testing/fixture_resolver_test.rb +20 -0
  998. data/vendor/rails/actionview/test/template/testing/null_resolver_test.rb +14 -0
  999. data/vendor/rails/actionview/test/template/text_helper_test.rb +535 -0
  1000. data/vendor/rails/actionview/test/template/text_test.rb +25 -0
  1001. data/vendor/rails/actionview/test/template/translation_helper_test.rb +238 -0
  1002. data/vendor/rails/actionview/test/template/url_helper_test.rb +976 -0
  1003. data/vendor/rails/actionview/test/ujs/config.ru +6 -0
  1004. data/vendor/rails/actionview/test/ujs/public/test/call-ajax.js +26 -0
  1005. data/vendor/rails/actionview/test/ujs/public/test/call-remote-callbacks.js +239 -0
  1006. data/vendor/rails/actionview/test/ujs/public/test/call-remote.js +275 -0
  1007. data/vendor/rails/actionview/test/ujs/public/test/csrf-refresh.js +24 -0
  1008. data/vendor/rails/actionview/test/ujs/public/test/csrf-token.js +27 -0
  1009. data/vendor/rails/actionview/test/ujs/public/test/data-confirm.js +316 -0
  1010. data/vendor/rails/actionview/test/ujs/public/test/data-disable-with.js +394 -0
  1011. data/vendor/rails/actionview/test/ujs/public/test/data-disable.js +322 -0
  1012. data/vendor/rails/actionview/test/ujs/public/test/data-method.js +85 -0
  1013. data/vendor/rails/actionview/test/ujs/public/test/data-remote.js +441 -0
  1014. data/vendor/rails/actionview/test/ujs/public/test/override.js +56 -0
  1015. data/vendor/rails/actionview/test/ujs/public/test/settings.js +118 -0
  1016. data/vendor/rails/actionview/test/ujs/public/vendor/jquery-2.2.0.js +9831 -0
  1017. data/vendor/rails/actionview/test/ujs/public/vendor/jquery.metadata.js +122 -0
  1018. data/vendor/rails/actionview/test/ujs/public/vendor/qunit.css +237 -0
  1019. data/vendor/rails/actionview/test/ujs/public/vendor/qunit.js +2288 -0
  1020. data/vendor/rails/actionview/test/ujs/server.rb +86 -0
  1021. data/vendor/rails/actionview/test/ujs/views/layouts/application.html.erb +26 -0
  1022. data/vendor/rails/actionview/test/ujs/views/tests/index.html.erb +11 -0
  1023. data/vendor/rails/ci/qunit-selenium-runner.rb +16 -0
  1024. data/vendor/rails/ci/travis.rb +187 -0
  1025. data/vendor/rails/rails.gemspec +36 -0
  1026. data/vendor/rails/version.rb +17 -0
  1027. metadata +1030 -30
@@ -0,0 +1,3554 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "abstract_unit"
4
+ require "controller/fake_models"
5
+
6
+ class FormHelperTest < ActionView::TestCase
7
+ include RenderERBUtils
8
+
9
+ tests ActionView::Helpers::FormHelper
10
+
11
+ class WithActiveStorageRoutesControllers < ActionController::Base
12
+ test_routes do
13
+ post "/rails/active_storage/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads
14
+ end
15
+
16
+ def url_options
17
+ { host: "testtwo.host" }
18
+ end
19
+ end
20
+
21
+ def form_for(*)
22
+ @output_buffer = super
23
+ end
24
+
25
+ teardown do
26
+ I18n.backend.reload!
27
+ end
28
+
29
+ setup do
30
+ # Create "label" locale for testing I18n label helpers
31
+ I18n.backend.store_translations "label",
32
+ activemodel: {
33
+ attributes: {
34
+ post: {
35
+ cost: "Total cost"
36
+ },
37
+ "post/language": {
38
+ spanish: "Espanol"
39
+ }
40
+ }
41
+ },
42
+ helpers: {
43
+ label: {
44
+ post: {
45
+ body: "Write entire text here",
46
+ color: {
47
+ red: "Rojo"
48
+ },
49
+ comments: {
50
+ body: "Write body here"
51
+ }
52
+ },
53
+ tag: {
54
+ value: "Tag"
55
+ },
56
+ post_delegate: {
57
+ title: "Delegate model_name title"
58
+ }
59
+ }
60
+ }
61
+
62
+ # Create "submit" locale for testing I18n submit helpers
63
+ I18n.backend.store_translations "submit",
64
+ helpers: {
65
+ submit: {
66
+ create: "Create %{model}",
67
+ update: "Confirm %{model} changes",
68
+ submit: "Save changes",
69
+ another_post: {
70
+ update: "Update your %{model}"
71
+ }
72
+ }
73
+ }
74
+
75
+ I18n.backend.store_translations "placeholder",
76
+ activemodel: {
77
+ attributes: {
78
+ post: {
79
+ cost: "Total cost"
80
+ },
81
+ "post/cost": {
82
+ uk: "Pounds"
83
+ }
84
+ }
85
+ },
86
+ helpers: {
87
+ placeholder: {
88
+ post: {
89
+ title: "What is this about?",
90
+ written_on: {
91
+ spanish: "Escrito en"
92
+ },
93
+ comments: {
94
+ body: "Write body here"
95
+ }
96
+ },
97
+ post_delegate: {
98
+ title: "Delegate model_name title"
99
+ },
100
+ tag: {
101
+ value: "Tag"
102
+ }
103
+ }
104
+ }
105
+
106
+ @post = Post.new
107
+ @comment = Comment.new
108
+ def @post.errors
109
+ Class.new {
110
+ def [](field); field == "author_name" ? ["can't be empty"] : [] end
111
+ def empty?() false end
112
+ def count() 1 end
113
+ def full_messages() ["Author name can't be empty"] end
114
+ }.new
115
+ end
116
+ def @post.to_key; [123]; end
117
+ def @post.id; 0; end
118
+ def @post.id_before_type_cast; "omg"; end
119
+ def @post.id_came_from_user?; true; end
120
+ def @post.to_param; "123"; end
121
+
122
+ @post.persisted = true
123
+ @post.title = "Hello World"
124
+ @post.author_name = ""
125
+ @post.body = "Back to the hill and over it again!"
126
+ @post.secret = 1
127
+ @post.written_on = Date.new(2004, 6, 15)
128
+
129
+ @post.comments = []
130
+ @post.comments << @comment
131
+
132
+ @post.tags = []
133
+ @post.tags << Tag.new
134
+
135
+ @post_delegator = PostDelegator.new
136
+
137
+ @post_delegator.title = "Hello World"
138
+
139
+ @car = Car.new("#000FFF")
140
+ end
141
+
142
+ Routes = ActionDispatch::Routing::RouteSet.new
143
+ Routes.draw do
144
+ resources :posts do
145
+ resources :comments
146
+ end
147
+
148
+ namespace :admin do
149
+ resources :posts do
150
+ resources :comments
151
+ end
152
+ end
153
+
154
+ get "/foo", to: "controller#action"
155
+ root to: "main#index"
156
+ end
157
+
158
+ def _routes
159
+ Routes
160
+ end
161
+
162
+ include Routes.url_helpers
163
+
164
+ def url_for(object)
165
+ @url_for_options = object
166
+
167
+ if object.is_a?(Hash) && object[:use_route].blank? && object[:controller].blank?
168
+ object.merge!(controller: "main", action: "index")
169
+ end
170
+
171
+ super
172
+ end
173
+
174
+ class FooTag < ActionView::Helpers::Tags::Base
175
+ def initialize; end
176
+ end
177
+
178
+ def test_tags_base_child_without_render_method
179
+ assert_raise(NotImplementedError) { FooTag.new.render }
180
+ end
181
+
182
+ def test_label
183
+ assert_dom_equal('<label for="post_title">Title</label>', label("post", "title"))
184
+ assert_dom_equal(
185
+ '<label for="post_title">The title goes here</label>',
186
+ label("post", "title", "The title goes here")
187
+ )
188
+ assert_dom_equal(
189
+ '<label class="title_label" for="post_title">Title</label>',
190
+ label("post", "title", nil, class: "title_label")
191
+ )
192
+ assert_dom_equal('<label for="post_secret">Secret?</label>', label("post", "secret?"))
193
+ end
194
+
195
+ def test_label_with_symbols
196
+ assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title))
197
+ assert_dom_equal('<label for="post_secret">Secret?</label>', label(:post, :secret?))
198
+ end
199
+
200
+ def test_label_with_locales_strings
201
+ with_locale :label do
202
+ assert_dom_equal('<label for="post_body">Write entire text here</label>', label("post", "body"))
203
+ end
204
+ end
205
+
206
+ def test_label_with_human_attribute_name
207
+ with_locale :label do
208
+ assert_dom_equal('<label for="post_cost">Total cost</label>', label(:post, :cost))
209
+ end
210
+ end
211
+
212
+ def test_label_with_human_attribute_name_and_options
213
+ with_locale :label do
214
+ assert_dom_equal('<label for="post_language_spanish">Espanol</label>', label(:post, :language, value: "spanish"))
215
+ end
216
+ end
217
+
218
+ def test_label_with_locales_symbols
219
+ with_locale :label do
220
+ assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body))
221
+ end
222
+ end
223
+
224
+ def test_label_with_locales_and_options
225
+ with_locale :label do
226
+ assert_dom_equal(
227
+ '<label for="post_body" class="post_body">Write entire text here</label>',
228
+ label(:post, :body, class: "post_body")
229
+ )
230
+ end
231
+ end
232
+
233
+ def test_label_with_locales_and_value
234
+ with_locale :label do
235
+ assert_dom_equal('<label for="post_color_red">Rojo</label>', label(:post, :color, value: "red"))
236
+ end
237
+ end
238
+
239
+ def test_label_with_locales_and_nested_attributes
240
+ with_locale :label do
241
+ form_for(@post, html: { id: "create-post" }) do |f|
242
+ f.fields_for(:comments) do |cf|
243
+ concat cf.label(:body)
244
+ end
245
+ end
246
+
247
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
248
+ '<label for="post_comments_attributes_0_body">Write body here</label>'
249
+ end
250
+
251
+ assert_dom_equal expected, output_buffer
252
+ end
253
+ end
254
+
255
+ def test_label_with_locales_fallback_and_nested_attributes
256
+ with_locale :label do
257
+ form_for(@post, html: { id: "create-post" }) do |f|
258
+ f.fields_for(:tags) do |cf|
259
+ concat cf.label(:value)
260
+ end
261
+ end
262
+
263
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
264
+ '<label for="post_tags_attributes_0_value">Tag</label>'
265
+ end
266
+
267
+ assert_dom_equal expected, output_buffer
268
+ end
269
+ end
270
+
271
+ def test_label_with_non_active_record_object
272
+ form_for(OpenStruct.new(name: "ok"), as: "person", url: "/an", html: { id: "create-person" }) do |f|
273
+ f.label(:name)
274
+ end
275
+
276
+ expected = whole_form("/an", "create-person", "new_person", method: "post") do
277
+ '<label for="person_name">Name</label>'
278
+ end
279
+
280
+ assert_dom_equal expected, output_buffer
281
+ end
282
+
283
+ def test_label_with_for_attribute_as_symbol
284
+ assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, for: "my_for"))
285
+ end
286
+
287
+ def test_label_with_for_attribute_as_string
288
+ assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, "for" => "my_for"))
289
+ end
290
+
291
+ def test_label_does_not_generate_for_attribute_when_given_nil
292
+ assert_dom_equal("<label>Title</label>", label(:post, :title, for: nil))
293
+ end
294
+
295
+ def test_label_with_id_attribute_as_symbol
296
+ assert_dom_equal(
297
+ '<label for="post_title" id="my_id">Title</label>',
298
+ label(:post, :title, nil, id: "my_id")
299
+ )
300
+ end
301
+
302
+ def test_label_with_id_attribute_as_string
303
+ assert_dom_equal(
304
+ '<label for="post_title" id="my_id">Title</label>',
305
+ label(:post, :title, nil, "id" => "my_id")
306
+ )
307
+ end
308
+
309
+ def test_label_with_for_and_id_attributes_as_symbol
310
+ assert_dom_equal(
311
+ '<label for="my_for" id="my_id">Title</label>',
312
+ label(:post, :title, nil, for: "my_for", id: "my_id")
313
+ )
314
+ end
315
+
316
+ def test_label_with_for_and_id_attributes_as_string
317
+ assert_dom_equal(
318
+ '<label for="my_for" id="my_id">Title</label>',
319
+ label(:post, :title, nil, "for" => "my_for", "id" => "my_id")
320
+ )
321
+ end
322
+
323
+ def test_label_for_radio_buttons_with_value
324
+ assert_dom_equal(
325
+ '<label for="post_title_great_title">The title goes here</label>',
326
+ label("post", "title", "The title goes here", value: "great_title")
327
+ )
328
+ assert_dom_equal(
329
+ '<label for="post_title_great_title">The title goes here</label>',
330
+ label("post", "title", "The title goes here", value: "great title")
331
+ )
332
+ end
333
+
334
+ def test_label_with_block
335
+ assert_dom_equal(
336
+ '<label for="post_title">The title, please:</label>',
337
+ label(:post, :title) { "The title, please:" }
338
+ )
339
+ end
340
+
341
+ def test_label_with_block_and_html
342
+ assert_dom_equal(
343
+ '<label for="post_terms">Accept <a href="/terms">Terms</a>.</label>',
344
+ label(:post, :terms) { raw('Accept <a href="/terms">Terms</a>.') }
345
+ )
346
+ end
347
+
348
+ def test_label_with_block_and_options
349
+ assert_dom_equal(
350
+ '<label for="my_for">The title, please:</label>',
351
+ label(:post, :title, "for" => "my_for") { "The title, please:" }
352
+ )
353
+ end
354
+
355
+ def test_label_with_block_and_builder
356
+ with_locale :label do
357
+ assert_dom_equal(
358
+ '<label for="post_body"><b>Write entire text here</b></label>',
359
+ label(:post, :body) { |b| raw("<b>#{b.translation}</b>") }
360
+ )
361
+ end
362
+ end
363
+
364
+ def test_label_with_block_in_erb
365
+ assert_dom_equal(
366
+ %{<label for="post_message">\n Message\n <input id="post_message" name="post[message]" type="text" />\n</label>},
367
+ view.render("test/label_with_block")
368
+ )
369
+ end
370
+
371
+ def test_label_with_to_model
372
+ assert_dom_equal(
373
+ %{<label for="post_delegator_title">Delegate Title</label>},
374
+ label(:post_delegator, :title)
375
+ )
376
+ end
377
+
378
+ def test_label_with_to_model_and_overridden_model_name
379
+ with_locale :label do
380
+ assert_dom_equal(
381
+ %{<label for="post_delegator_title">Delegate model_name title</label>},
382
+ label(:post_delegator, :title)
383
+ )
384
+ end
385
+ end
386
+
387
+ def test_text_field_placeholder_without_locales
388
+ with_locale :placeholder do
389
+ assert_dom_equal('<input id="post_body" name="post[body]" placeholder="Body" type="text" value="Back to the hill and over it again!" />', text_field(:post, :body, placeholder: true))
390
+ end
391
+ end
392
+
393
+ def test_text_field_placeholder_with_locales
394
+ with_locale :placeholder do
395
+ assert_dom_equal('<input id="post_title" name="post[title]" placeholder="What is this about?" type="text" value="Hello World" />', text_field(:post, :title, placeholder: true))
396
+ end
397
+ end
398
+
399
+ def test_text_field_placeholder_with_locales_and_to_model
400
+ with_locale :placeholder do
401
+ assert_dom_equal(
402
+ '<input id="post_delegator_title" name="post_delegator[title]" placeholder="Delegate model_name title" type="text" value="Hello World" />',
403
+ text_field(:post_delegator, :title, placeholder: true)
404
+ )
405
+ end
406
+ end
407
+
408
+ def test_text_field_placeholder_with_human_attribute_name
409
+ with_locale :placeholder do
410
+ assert_dom_equal('<input id="post_cost" name="post[cost]" placeholder="Total cost" type="text" />', text_field(:post, :cost, placeholder: true))
411
+ end
412
+ end
413
+
414
+ def test_text_field_placeholder_with_human_attribute_name_and_to_model
415
+ assert_dom_equal(
416
+ '<input id="post_delegator_title" name="post_delegator[title]" placeholder="Delegate Title" type="text" value="Hello World" />',
417
+ text_field(:post_delegator, :title, placeholder: true)
418
+ )
419
+ end
420
+
421
+ def test_text_field_placeholder_with_string_value
422
+ with_locale :placeholder do
423
+ assert_dom_equal('<input id="post_cost" name="post[cost]" placeholder="HOW MUCH?" type="text" />', text_field(:post, :cost, placeholder: "HOW MUCH?"))
424
+ end
425
+ end
426
+
427
+ def test_text_field_placeholder_with_human_attribute_name_and_value
428
+ with_locale :placeholder do
429
+ assert_dom_equal('<input id="post_cost" name="post[cost]" placeholder="Pounds" type="text" />', text_field(:post, :cost, placeholder: :uk))
430
+ end
431
+ end
432
+
433
+ def test_text_field_placeholder_with_locales_and_value
434
+ with_locale :placeholder do
435
+ assert_dom_equal('<input id="post_written_on" name="post[written_on]" placeholder="Escrito en" type="text" value="2004-06-15" />', text_field(:post, :written_on, placeholder: :spanish))
436
+ end
437
+ end
438
+
439
+ def test_text_field_placeholder_with_locales_and_nested_attributes
440
+ with_locale :placeholder do
441
+ form_for(@post, html: { id: "create-post" }) do |f|
442
+ f.fields_for(:comments) do |cf|
443
+ concat cf.text_field(:body, placeholder: true)
444
+ end
445
+ end
446
+
447
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
448
+ '<input id="post_comments_attributes_0_body" name="post[comments_attributes][0][body]" placeholder="Write body here" type="text" />'
449
+ end
450
+
451
+ assert_dom_equal expected, output_buffer
452
+ end
453
+ end
454
+
455
+ def test_text_field_placeholder_with_locales_fallback_and_nested_attributes
456
+ with_locale :placeholder do
457
+ form_for(@post, html: { id: "create-post" }) do |f|
458
+ f.fields_for(:tags) do |cf|
459
+ concat cf.text_field(:value, placeholder: true)
460
+ end
461
+ end
462
+
463
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
464
+ '<input id="post_tags_attributes_0_value" name="post[tags_attributes][0][value]" placeholder="Tag" type="text" value="new tag" />'
465
+ end
466
+
467
+ assert_dom_equal expected, output_buffer
468
+ end
469
+ end
470
+
471
+ def test_text_field
472
+ assert_dom_equal(
473
+ '<input id="post_title" name="post[title]" type="text" value="Hello World" />',
474
+ text_field("post", "title")
475
+ )
476
+ assert_dom_equal(
477
+ '<input id="post_title" name="post[title]" type="password" />',
478
+ password_field("post", "title")
479
+ )
480
+ assert_dom_equal(
481
+ '<input id="post_title" name="post[title]" type="password" value="Hello World" />',
482
+ password_field("post", "title", value: @post.title)
483
+ )
484
+ assert_dom_equal(
485
+ '<input id="person_name" name="person[name]" type="password" />',
486
+ password_field("person", "name")
487
+ )
488
+ end
489
+
490
+ def test_text_field_with_escapes
491
+ @post.title = "<b>Hello World</b>"
492
+ assert_dom_equal(
493
+ '<input id="post_title" name="post[title]" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;" />',
494
+ text_field("post", "title")
495
+ )
496
+ end
497
+
498
+ def test_text_field_with_html_entities
499
+ @post.title = "The HTML Entity for & is &amp;"
500
+ assert_dom_equal(
501
+ '<input id="post_title" name="post[title]" type="text" value="The HTML Entity for &amp; is &amp;amp;" />',
502
+ text_field("post", "title")
503
+ )
504
+ end
505
+
506
+ def test_text_field_with_options
507
+ expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />'
508
+ assert_dom_equal expected, text_field("post", "title", "size" => 35)
509
+ assert_dom_equal expected, text_field("post", "title", size: 35)
510
+ end
511
+
512
+ def test_text_field_assuming_size
513
+ expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />'
514
+ assert_dom_equal expected, text_field("post", "title", "maxlength" => 35)
515
+ assert_dom_equal expected, text_field("post", "title", maxlength: 35)
516
+ end
517
+
518
+ def test_text_field_removing_size
519
+ expected = '<input id="post_title" maxlength="35" name="post[title]" type="text" value="Hello World" />'
520
+ assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil)
521
+ assert_dom_equal expected, text_field("post", "title", maxlength: 35, size: nil)
522
+ end
523
+
524
+ def test_text_field_with_nil_value
525
+ expected = '<input id="post_title" name="post[title]" type="text" />'
526
+ assert_dom_equal expected, text_field("post", "title", value: nil)
527
+ end
528
+
529
+ def test_text_field_with_nil_name
530
+ expected = '<input id="post_title" type="text" value="Hello World" />'
531
+ assert_dom_equal expected, text_field("post", "title", name: nil)
532
+ end
533
+
534
+ def test_text_field_doesnt_change_param_values
535
+ object_name = "post[]"
536
+ expected = '<input id="post_123_title" name="post[123][title]" type="text" value="Hello World" />'
537
+ assert_dom_equal expected, text_field(object_name, "title")
538
+ end
539
+
540
+ def test_file_field_has_no_size
541
+ expected = '<input id="user_avatar" name="user[avatar]" type="file" />'
542
+ assert_dom_equal expected, file_field("user", "avatar")
543
+ end
544
+
545
+ def test_file_field_with_multiple_behavior
546
+ expected = '<input id="import_file" multiple="multiple" name="import[file][]" type="file" />'
547
+ assert_dom_equal expected, file_field("import", "file", multiple: true)
548
+ end
549
+
550
+ def test_file_field_with_multiple_behavior_and_explicit_name
551
+ expected = '<input id="import_file" multiple="multiple" name="custom" type="file" />'
552
+ assert_dom_equal expected, file_field("import", "file", multiple: true, name: "custom")
553
+ end
554
+
555
+ def test_file_field_with_direct_upload_when_rails_direct_uploads_url_is_not_defined
556
+ expected = '<input type="file" name="import[file]" id="import_file" />'
557
+ assert_dom_equal expected, file_field("import", "file", direct_upload: true)
558
+ end
559
+
560
+ def test_file_field_with_direct_upload_when_rails_direct_uploads_url_is_defined
561
+ @controller = WithActiveStorageRoutesControllers.new
562
+
563
+ expected = '<input data-direct-upload-url="http://testtwo.host/rails/active_storage/direct_uploads" type="file" name="import[file]" id="import_file" />'
564
+ assert_dom_equal expected, file_field("import", "file", direct_upload: true)
565
+ end
566
+
567
+ def test_file_field_with_direct_upload_dont_mutate_arguments
568
+ original_options = { class: "pix", direct_upload: true }
569
+
570
+ expected = '<input class="pix" type="file" name="import[file]" id="import_file" />'
571
+ assert_dom_equal expected, file_field("import", "file", original_options)
572
+
573
+ assert_equal({ class: "pix", direct_upload: true }, original_options)
574
+ end
575
+
576
+ def test_hidden_field
577
+ assert_dom_equal(
578
+ '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />',
579
+ hidden_field("post", "title")
580
+ )
581
+ assert_dom_equal(
582
+ '<input id="post_secret" name="post[secret]" type="hidden" value="1" />',
583
+ hidden_field("post", "secret?")
584
+ )
585
+ end
586
+
587
+ def test_hidden_field_with_escapes
588
+ @post.title = "<b>Hello World</b>"
589
+ assert_dom_equal(
590
+ '<input id="post_title" name="post[title]" type="hidden" value="&lt;b&gt;Hello World&lt;/b&gt;" />',
591
+ hidden_field("post", "title")
592
+ )
593
+ end
594
+
595
+ def test_hidden_field_with_nil_value
596
+ expected = '<input id="post_title" name="post[title]" type="hidden" />'
597
+ assert_dom_equal expected, hidden_field("post", "title", value: nil)
598
+ end
599
+
600
+ def test_hidden_field_with_options
601
+ assert_dom_equal(
602
+ '<input id="post_title" name="post[title]" type="hidden" value="Something Else" />',
603
+ hidden_field("post", "title", value: "Something Else")
604
+ )
605
+ end
606
+
607
+ def test_text_field_with_custom_type
608
+ assert_dom_equal(
609
+ '<input id="user_email" name="user[email]" type="email" />',
610
+ text_field("user", "email", type: "email")
611
+ )
612
+ end
613
+
614
+ def test_check_box_is_html_safe
615
+ assert_predicate check_box("post", "secret"), :html_safe?
616
+ end
617
+
618
+ def test_check_box_checked_if_object_value_is_same_that_check_value
619
+ assert_dom_equal(
620
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
621
+ check_box("post", "secret")
622
+ )
623
+ end
624
+
625
+ def test_check_box_not_checked_if_object_value_is_same_that_unchecked_value
626
+ @post.secret = 0
627
+ assert_dom_equal(
628
+ '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
629
+ check_box("post", "secret")
630
+ )
631
+ end
632
+
633
+ def test_check_box_checked_if_option_checked_is_present
634
+ assert_dom_equal(
635
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
636
+ check_box("post", "secret", "checked" => "checked")
637
+ )
638
+ end
639
+
640
+ def test_check_box_checked_if_object_value_is_true
641
+ @post.secret = true
642
+ assert_dom_equal(
643
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
644
+ check_box("post", "secret")
645
+ )
646
+
647
+ assert_dom_equal(
648
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
649
+ check_box("post", "secret?")
650
+ )
651
+ end
652
+
653
+ def test_check_box_checked_if_object_value_includes_checked_value
654
+ @post.secret = ["0"]
655
+ assert_dom_equal(
656
+ '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
657
+ check_box("post", "secret")
658
+ )
659
+
660
+ @post.secret = ["1"]
661
+ assert_dom_equal(
662
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
663
+ check_box("post", "secret")
664
+ )
665
+
666
+ @post.secret = Set.new(["1"])
667
+ assert_dom_equal(
668
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
669
+ check_box("post", "secret")
670
+ )
671
+ end
672
+
673
+ def test_check_box_with_include_hidden_false
674
+ @post.secret = false
675
+ assert_dom_equal(
676
+ '<input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
677
+ check_box("post", "secret", include_hidden: false)
678
+ )
679
+ end
680
+
681
+ def test_check_box_with_explicit_checked_and_unchecked_values_when_object_value_is_string
682
+ @post.secret = "on"
683
+ assert_dom_equal(
684
+ '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
685
+ check_box("post", "secret", {}, "on", "off")
686
+ )
687
+
688
+ @post.secret = "off"
689
+ assert_dom_equal(
690
+ '<input name="post[secret]" type="hidden" value="off" /><input id="post_secret" name="post[secret]" type="checkbox" value="on" />',
691
+ check_box("post", "secret", {}, "on", "off")
692
+ )
693
+ end
694
+
695
+ def test_check_box_with_explicit_checked_and_unchecked_values_when_object_value_is_boolean
696
+ @post.secret = false
697
+ assert_dom_equal(
698
+ '<input name="post[secret]" type="hidden" value="true" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="false" />',
699
+ check_box("post", "secret", {}, false, true)
700
+ )
701
+
702
+ @post.secret = true
703
+ assert_dom_equal(
704
+ '<input name="post[secret]" type="hidden" value="true" /><input id="post_secret" name="post[secret]" type="checkbox" value="false" />',
705
+ check_box("post", "secret", {}, false, true)
706
+ )
707
+ end
708
+
709
+ def test_check_box_with_explicit_checked_and_unchecked_values_when_object_value_is_integer
710
+ @post.secret = 0
711
+ assert_dom_equal(
712
+ '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="0" />',
713
+ check_box("post", "secret", {}, 0, 1)
714
+ )
715
+
716
+ @post.secret = 1
717
+ assert_dom_equal(
718
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
719
+ check_box("post", "secret", {}, 0, 1)
720
+ )
721
+
722
+ @post.secret = 2
723
+ assert_dom_equal(
724
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
725
+ check_box("post", "secret", {}, 0, 1)
726
+ )
727
+ end
728
+
729
+ def test_check_box_with_explicit_checked_and_unchecked_values_when_object_value_is_float
730
+ @post.secret = 0.0
731
+ assert_dom_equal(
732
+ '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="0" />',
733
+ check_box("post", "secret", {}, 0, 1)
734
+ )
735
+
736
+ @post.secret = 1.1
737
+ assert_dom_equal(
738
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
739
+ check_box("post", "secret", {}, 0, 1)
740
+ )
741
+
742
+ @post.secret = 2.2
743
+ assert_dom_equal(
744
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
745
+ check_box("post", "secret", {}, 0, 1)
746
+ )
747
+ end
748
+
749
+ def test_check_box_with_explicit_checked_and_unchecked_values_when_object_value_is_big_decimal
750
+ @post.secret = BigDecimal(0)
751
+ assert_dom_equal(
752
+ '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="0" />',
753
+ check_box("post", "secret", {}, 0, 1)
754
+ )
755
+
756
+ @post.secret = BigDecimal(1)
757
+ assert_dom_equal(
758
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
759
+ check_box("post", "secret", {}, 0, 1)
760
+ )
761
+
762
+ @post.secret = BigDecimal(2.2, 1)
763
+ assert_dom_equal(
764
+ '<input name="post[secret]" type="hidden" value="1" /><input id="post_secret" name="post[secret]" type="checkbox" value="0" />',
765
+ check_box("post", "secret", {}, 0, 1)
766
+ )
767
+ end
768
+
769
+ def test_check_box_with_nil_unchecked_value
770
+ @post.secret = "on"
771
+ assert_dom_equal(
772
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
773
+ check_box("post", "secret", {}, "on", nil)
774
+ )
775
+ end
776
+
777
+ def test_check_box_with_nil_unchecked_value_is_html_safe
778
+ assert_predicate check_box("post", "secret", {}, "on", nil), :html_safe?
779
+ end
780
+
781
+ def test_check_box_with_multiple_behavior
782
+ @post.comment_ids = [2, 3]
783
+ assert_dom_equal(
784
+ '<input name="post[comment_ids][]" type="hidden" value="0" /><input id="post_comment_ids_1" name="post[comment_ids][]" type="checkbox" value="1" />',
785
+ check_box("post", "comment_ids", { multiple: true }, 1)
786
+ )
787
+ assert_dom_equal(
788
+ '<input name="post[comment_ids][]" type="hidden" value="0" /><input checked="checked" id="post_comment_ids_3" name="post[comment_ids][]" type="checkbox" value="3" />',
789
+ check_box("post", "comment_ids", { multiple: true }, 3)
790
+ )
791
+ end
792
+
793
+ def test_check_box_with_multiple_behavior_and_index
794
+ @post.comment_ids = [2, 3]
795
+ assert_dom_equal(
796
+ '<input name="post[foo][comment_ids][]" type="hidden" value="0" /><input id="post_foo_comment_ids_1" name="post[foo][comment_ids][]" type="checkbox" value="1" />',
797
+ check_box("post", "comment_ids", { multiple: true, index: "foo" }, 1)
798
+ )
799
+ assert_dom_equal(
800
+ '<input name="post[bar][comment_ids][]" type="hidden" value="0" /><input checked="checked" id="post_bar_comment_ids_3" name="post[bar][comment_ids][]" type="checkbox" value="3" />',
801
+ check_box("post", "comment_ids", { multiple: true, index: "bar" }, 3)
802
+ )
803
+ end
804
+
805
+ def test_checkbox_disabled_disables_hidden_field
806
+ assert_dom_equal(
807
+ '<input name="post[secret]" type="hidden" value="0" disabled="disabled"/><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
808
+ check_box("post", "secret", disabled: true)
809
+ )
810
+ end
811
+
812
+ def test_checkbox_form_html5_attribute
813
+ assert_dom_equal(
814
+ '<input form="new_form" name="post[secret]" type="hidden" value="0" /><input checked="checked" form="new_form" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
815
+ check_box("post", "secret", form: "new_form")
816
+ )
817
+ end
818
+
819
+ def test_radio_button
820
+ assert_dom_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />',
821
+ radio_button("post", "title", "Hello World")
822
+ )
823
+ assert_dom_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />',
824
+ radio_button("post", "title", "Goodbye World")
825
+ )
826
+ assert_dom_equal('<input id="item_subobject_title_inside_world" name="item[subobject][title]" type="radio" value="inside world"/>',
827
+ radio_button("item[subobject]", "title", "inside world")
828
+ )
829
+ end
830
+
831
+ def test_radio_button_is_checked_with_integers
832
+ assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />',
833
+ radio_button("post", "secret", "1")
834
+ )
835
+ end
836
+
837
+ def test_radio_button_with_negative_integer_value
838
+ assert_dom_equal('<input id="post_secret_-1" name="post[secret]" type="radio" value="-1" />',
839
+ radio_button("post", "secret", "-1"))
840
+ end
841
+
842
+ def test_radio_button_respects_passed_in_id
843
+ assert_dom_equal('<input checked="checked" id="foo" name="post[secret]" type="radio" value="1" />',
844
+ radio_button("post", "secret", "1", id: "foo")
845
+ )
846
+ end
847
+
848
+ def test_radio_button_with_booleans
849
+ assert_dom_equal('<input id="post_secret_true" name="post[secret]" type="radio" value="true" />',
850
+ radio_button("post", "secret", true)
851
+ )
852
+
853
+ assert_dom_equal('<input id="post_secret_false" name="post[secret]" type="radio" value="false" />',
854
+ radio_button("post", "secret", false)
855
+ )
856
+ end
857
+
858
+ def test_text_area_placeholder_without_locales
859
+ with_locale :placeholder do
860
+ assert_dom_equal(
861
+ %{<textarea id="post_body" name="post[body]" placeholder="Body">\nBack to the hill and over it again!</textarea>},
862
+ text_area(:post, :body, placeholder: true)
863
+ )
864
+ end
865
+ end
866
+
867
+ def test_text_area_placeholder_with_locales
868
+ with_locale :placeholder do
869
+ assert_dom_equal(
870
+ %{<textarea id="post_title" name="post[title]" placeholder="What is this about?">\nHello World</textarea>},
871
+ text_area(:post, :title, placeholder: true)
872
+ )
873
+ end
874
+ end
875
+
876
+ def test_text_area_placeholder_with_human_attribute_name
877
+ with_locale :placeholder do
878
+ assert_dom_equal(
879
+ %{<textarea id="post_cost" name="post[cost]" placeholder="Total cost">\n</textarea>},
880
+ text_area(:post, :cost, placeholder: true)
881
+ )
882
+ end
883
+ end
884
+
885
+ def test_text_area_placeholder_with_string_value
886
+ with_locale :placeholder do
887
+ assert_dom_equal(
888
+ %{<textarea id="post_cost" name="post[cost]" placeholder="HOW MUCH?">\n</textarea>},
889
+ text_area(:post, :cost, placeholder: "HOW MUCH?")
890
+ )
891
+ end
892
+ end
893
+
894
+ def test_text_area_placeholder_with_human_attribute_name_and_value
895
+ with_locale :placeholder do
896
+ assert_dom_equal(
897
+ %{<textarea id="post_cost" name="post[cost]" placeholder="Pounds">\n</textarea>},
898
+ text_area(:post, :cost, placeholder: :uk)
899
+ )
900
+ end
901
+ end
902
+
903
+ def test_text_area_placeholder_with_locales_and_value
904
+ with_locale :placeholder do
905
+ assert_dom_equal(
906
+ %{<textarea id="post_written_on" name="post[written_on]" placeholder="Escrito en">\n2004-06-15</textarea>},
907
+ text_area(:post, :written_on, placeholder: :spanish)
908
+ )
909
+ end
910
+ end
911
+
912
+ def test_text_area_placeholder_with_locales_and_nested_attributes
913
+ with_locale :placeholder do
914
+ form_for(@post, html: { id: "create-post" }) do |f|
915
+ f.fields_for(:comments) do |cf|
916
+ concat cf.text_area(:body, placeholder: true)
917
+ end
918
+ end
919
+
920
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
921
+ %{<textarea id="post_comments_attributes_0_body" name="post[comments_attributes][0][body]" placeholder="Write body here">\n</textarea>}
922
+ end
923
+
924
+ assert_dom_equal expected, output_buffer
925
+ end
926
+ end
927
+
928
+ def test_text_area_placeholder_with_locales_fallback_and_nested_attributes
929
+ with_locale :placeholder do
930
+ form_for(@post, html: { id: "create-post" }) do |f|
931
+ f.fields_for(:tags) do |cf|
932
+ concat cf.text_area(:value, placeholder: true)
933
+ end
934
+ end
935
+
936
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
937
+ %{<textarea id="post_tags_attributes_0_value" name="post[tags_attributes][0][value]" placeholder="Tag">\nnew tag</textarea>}
938
+ end
939
+
940
+ assert_dom_equal expected, output_buffer
941
+ end
942
+ end
943
+
944
+ def test_text_area
945
+ assert_dom_equal(
946
+ %{<textarea id="post_body" name="post[body]">\nBack to the hill and over it again!</textarea>},
947
+ text_area("post", "body")
948
+ )
949
+ end
950
+
951
+ def test_text_area_with_escapes
952
+ @post.body = "Back to <i>the</i> hill and over it again!"
953
+ assert_dom_equal(
954
+ %{<textarea id="post_body" name="post[body]">\nBack to &lt;i&gt;the&lt;/i&gt; hill and over it again!</textarea>},
955
+ text_area("post", "body")
956
+ )
957
+ end
958
+
959
+ def test_text_area_with_alternate_value
960
+ assert_dom_equal(
961
+ %{<textarea id="post_body" name="post[body]">\nTesting alternate values.</textarea>},
962
+ text_area("post", "body", value: "Testing alternate values.")
963
+ )
964
+ end
965
+
966
+ def test_text_area_with_nil_alternate_value
967
+ assert_dom_equal(
968
+ %{<textarea id="post_body" name="post[body]">\n</textarea>},
969
+ text_area("post", "body", value: nil)
970
+ )
971
+ end
972
+
973
+ def test_inputs_use_before_type_cast_to_retain_information_from_validations_like_numericality
974
+ assert_dom_equal(
975
+ %{<textarea id="post_id" name="post[id]">\nomg</textarea>},
976
+ text_area("post", "id")
977
+ )
978
+ end
979
+
980
+ def test_inputs_dont_use_before_type_cast_when_value_did_not_come_from_user
981
+ class << @post
982
+ undef id_came_from_user?
983
+ def id_came_from_user?; false; end
984
+ end
985
+
986
+ assert_dom_equal(
987
+ %{<textarea id="post_id" name="post[id]">\n0</textarea>},
988
+ text_area("post", "id")
989
+ )
990
+ end
991
+
992
+ def test_inputs_use_before_typecast_when_object_doesnt_respond_to_came_from_user
993
+ class << @post; undef id_came_from_user?; end
994
+ assert_dom_equal(
995
+ %{<textarea id="post_id" name="post[id]">\nomg</textarea>},
996
+ text_area("post", "id")
997
+ )
998
+ end
999
+
1000
+ def test_text_area_with_html_entities
1001
+ @post.body = "The HTML Entity for & is &amp;"
1002
+ assert_dom_equal(
1003
+ %{<textarea id="post_body" name="post[body]">\nThe HTML Entity for &amp; is &amp;amp;</textarea>},
1004
+ text_area("post", "body")
1005
+ )
1006
+ end
1007
+
1008
+ def test_text_area_with_size_option
1009
+ assert_dom_equal(
1010
+ %{<textarea cols="183" id="post_body" name="post[body]" rows="820">\nBack to the hill and over it again!</textarea>},
1011
+ text_area("post", "body", size: "183x820")
1012
+ )
1013
+ end
1014
+
1015
+ def test_color_field_with_valid_hex_color_string
1016
+ expected = %{<input id="car_color" name="car[color]" type="color" value="#000fff" />}
1017
+ assert_dom_equal(expected, color_field("car", "color"))
1018
+ end
1019
+
1020
+ def test_color_field_with_invalid_hex_color_string
1021
+ expected = %{<input id="car_color" name="car[color]" type="color" value="#000000" />}
1022
+ @car.color = "#1234TR"
1023
+ assert_dom_equal(expected, color_field("car", "color"))
1024
+ end
1025
+
1026
+ def test_color_field_with_value_attr
1027
+ expected = %{<input id="car_color" name="car[color]" type="color" value="#00FF00" />}
1028
+ assert_dom_equal(expected, color_field("car", "color", value: "#00FF00"))
1029
+ end
1030
+
1031
+ def test_search_field
1032
+ expected = %{<input id="contact_notes_query" name="contact[notes_query]" type="search" />}
1033
+ assert_dom_equal(expected, search_field("contact", "notes_query"))
1034
+ end
1035
+
1036
+ def test_search_field_with_onsearch_value
1037
+ expected = %{<input onsearch="true" type="search" name="contact[notes_query]" id="contact_notes_query" incremental="true" />}
1038
+ assert_dom_equal(expected, search_field("contact", "notes_query", onsearch: true))
1039
+ end
1040
+
1041
+ def test_telephone_field
1042
+ expected = %{<input id="user_cell" name="user[cell]" type="tel" />}
1043
+ assert_dom_equal(expected, telephone_field("user", "cell"))
1044
+ end
1045
+
1046
+ def test_date_field
1047
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
1048
+ assert_dom_equal(expected, date_field("post", "written_on"))
1049
+ end
1050
+
1051
+ def test_date_field_with_datetime_value
1052
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
1053
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1054
+ assert_dom_equal(expected, date_field("post", "written_on"))
1055
+ end
1056
+
1057
+ def test_date_field_with_extra_attrs
1058
+ expected = %{<input id="post_written_on" step="2" max="2010-08-15" min="2000-06-15" name="post[written_on]" type="date" value="2004-06-15" />}
1059
+ @post.written_on = DateTime.new(2004, 6, 15)
1060
+ min_value = DateTime.new(2000, 6, 15)
1061
+ max_value = DateTime.new(2010, 8, 15)
1062
+ step = 2
1063
+ assert_dom_equal(expected, date_field("post", "written_on", min: min_value, max: max_value, step: step))
1064
+ end
1065
+
1066
+ def test_date_field_with_value_attr
1067
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2013-06-29" />}
1068
+ value = Date.new(2013, 6, 29)
1069
+ assert_dom_equal(expected, date_field("post", "written_on", value: value))
1070
+ end
1071
+
1072
+ def test_date_field_with_timewithzone_value
1073
+ previous_time_zone, Time.zone = Time.zone, "UTC"
1074
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
1075
+ @post.written_on = Time.zone.parse("2004-06-15 15:30:45")
1076
+ assert_dom_equal(expected, date_field("post", "written_on"))
1077
+ ensure
1078
+ Time.zone = previous_time_zone
1079
+ end
1080
+
1081
+ def test_date_field_with_nil_value
1082
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" />}
1083
+ @post.written_on = nil
1084
+ assert_dom_equal(expected, date_field("post", "written_on"))
1085
+ end
1086
+
1087
+ def test_date_field_with_string_values_for_min_and_max
1088
+ expected = %{<input id="post_written_on" max="2010-08-15" min="2000-06-15" name="post[written_on]" type="date" value="2004-06-15" />}
1089
+ @post.written_on = DateTime.new(2004, 6, 15)
1090
+ min_value = "2000-06-15"
1091
+ max_value = "2010-08-15"
1092
+ assert_dom_equal(expected, date_field("post", "written_on", min: min_value, max: max_value))
1093
+ end
1094
+
1095
+ def test_date_field_with_invalid_string_values_for_min_and_max
1096
+ expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
1097
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1098
+ min_value = "foo"
1099
+ max_value = "bar"
1100
+ assert_dom_equal(expected, date_field("post", "written_on", min: min_value, max: max_value))
1101
+ end
1102
+
1103
+ def test_time_field
1104
+ expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="00:00:00.000" />}
1105
+ assert_dom_equal(expected, time_field("post", "written_on"))
1106
+ end
1107
+
1108
+ def test_time_field_with_datetime_value
1109
+ expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />}
1110
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1111
+ assert_dom_equal(expected, time_field("post", "written_on"))
1112
+ end
1113
+
1114
+ def test_time_field_with_extra_attrs
1115
+ expected = %{<input id="post_written_on" step="60" max="10:25:00.000" min="20:45:30.000" name="post[written_on]" type="time" value="01:02:03.000" />}
1116
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1117
+ min_value = DateTime.new(2000, 6, 15, 20, 45, 30)
1118
+ max_value = DateTime.new(2010, 8, 15, 10, 25, 00)
1119
+ step = 60
1120
+ assert_dom_equal(expected, time_field("post", "written_on", min: min_value, max: max_value, step: step))
1121
+ end
1122
+
1123
+ def test_time_field_with_timewithzone_value
1124
+ previous_time_zone, Time.zone = Time.zone, "UTC"
1125
+ expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />}
1126
+ @post.written_on = Time.zone.parse("2004-06-15 01:02:03")
1127
+ assert_dom_equal(expected, time_field("post", "written_on"))
1128
+ ensure
1129
+ Time.zone = previous_time_zone
1130
+ end
1131
+
1132
+ def test_time_field_with_nil_value
1133
+ expected = %{<input id="post_written_on" name="post[written_on]" type="time" />}
1134
+ @post.written_on = nil
1135
+ assert_dom_equal(expected, time_field("post", "written_on"))
1136
+ end
1137
+
1138
+ def test_time_field_with_string_values_for_min_and_max
1139
+ expected = %{<input id="post_written_on" max="10:25:00.000" min="20:45:30.000" name="post[written_on]" type="time" value="01:02:03.000" />}
1140
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1141
+ min_value = "20:45:30.000"
1142
+ max_value = "10:25:00.000"
1143
+ assert_dom_equal(expected, time_field("post", "written_on", min: min_value, max: max_value))
1144
+ end
1145
+
1146
+ def test_time_field_with_invalid_string_values_for_min_and_max
1147
+ expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />}
1148
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1149
+ min_value = "foo"
1150
+ max_value = "bar"
1151
+ assert_dom_equal(expected, time_field("post", "written_on", min: min_value, max: max_value))
1152
+ end
1153
+
1154
+ def test_datetime_field
1155
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2004-06-15T00:00:00" />}
1156
+ assert_dom_equal(expected, datetime_field("post", "written_on"))
1157
+ end
1158
+
1159
+ def test_datetime_field_with_datetime_value
1160
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2004-06-15T01:02:03" />}
1161
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1162
+ assert_dom_equal(expected, datetime_field("post", "written_on"))
1163
+ end
1164
+
1165
+ def test_datetime_field_with_extra_attrs
1166
+ expected = %{<input id="post_written_on" step="60" max="2010-08-15T10:25:00" min="2000-06-15T20:45:30" name="post[written_on]" type="datetime-local" value="2004-06-15T01:02:03" />}
1167
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1168
+ min_value = DateTime.new(2000, 6, 15, 20, 45, 30)
1169
+ max_value = DateTime.new(2010, 8, 15, 10, 25, 00)
1170
+ step = 60
1171
+ assert_dom_equal(expected, datetime_field("post", "written_on", min: min_value, max: max_value, step: step))
1172
+ end
1173
+
1174
+ def test_datetime_field_with_value_attr
1175
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2013-06-29T13:37:00+00:00" />}
1176
+ value = DateTime.new(2013, 6, 29, 13, 37)
1177
+ assert_dom_equal(expected, datetime_field("post", "written_on", value: value))
1178
+ end
1179
+
1180
+ def test_datetime_field_with_timewithzone_value
1181
+ previous_time_zone, Time.zone = Time.zone, "UTC"
1182
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2004-06-15T15:30:45" />}
1183
+ @post.written_on = Time.zone.parse("2004-06-15 15:30:45")
1184
+ assert_dom_equal(expected, datetime_field("post", "written_on"))
1185
+ ensure
1186
+ Time.zone = previous_time_zone
1187
+ end
1188
+
1189
+ def test_datetime_field_with_nil_value
1190
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" />}
1191
+ @post.written_on = nil
1192
+ assert_dom_equal(expected, datetime_field("post", "written_on"))
1193
+ end
1194
+
1195
+ def test_datetime_field_with_string_values_for_min_and_max
1196
+ expected = %{<input id="post_written_on" max="2010-08-15T10:25:00" min="2000-06-15T20:45:30" name="post[written_on]" type="datetime-local" value="2004-06-15T01:02:03" />}
1197
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1198
+ min_value = "2000-06-15T20:45:30"
1199
+ max_value = "2010-08-15T10:25:00"
1200
+ assert_dom_equal(expected, datetime_field("post", "written_on", min: min_value, max: max_value))
1201
+ end
1202
+
1203
+ def test_datetime_field_with_invalid_string_values_for_min_and_max
1204
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2004-06-15T01:02:03" />}
1205
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1206
+ min_value = "foo"
1207
+ max_value = "bar"
1208
+ assert_dom_equal(expected, datetime_field("post", "written_on", min: min_value, max: max_value))
1209
+ end
1210
+
1211
+ def test_datetime_local_field
1212
+ expected = %{<input id="post_written_on" name="post[written_on]" type="datetime-local" value="2004-06-15T00:00:00" />}
1213
+ assert_dom_equal(expected, datetime_local_field("post", "written_on"))
1214
+ end
1215
+
1216
+ def test_month_field
1217
+ expected = %{<input id="post_written_on" name="post[written_on]" type="month" value="2004-06" />}
1218
+ assert_dom_equal(expected, month_field("post", "written_on"))
1219
+ end
1220
+
1221
+ def test_month_field_with_nil_value
1222
+ expected = %{<input id="post_written_on" name="post[written_on]" type="month" />}
1223
+ @post.written_on = nil
1224
+ assert_dom_equal(expected, month_field("post", "written_on"))
1225
+ end
1226
+
1227
+ def test_month_field_with_datetime_value
1228
+ expected = %{<input id="post_written_on" name="post[written_on]" type="month" value="2004-06" />}
1229
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1230
+ assert_dom_equal(expected, month_field("post", "written_on"))
1231
+ end
1232
+
1233
+ def test_month_field_with_extra_attrs
1234
+ expected = %{<input id="post_written_on" step="2" max="2010-12" min="2000-02" name="post[written_on]" type="month" value="2004-06" />}
1235
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1236
+ min_value = DateTime.new(2000, 2, 13)
1237
+ max_value = DateTime.new(2010, 12, 23)
1238
+ step = 2
1239
+ assert_dom_equal(expected, month_field("post", "written_on", min: min_value, max: max_value, step: step))
1240
+ end
1241
+
1242
+ def test_month_field_with_timewithzone_value
1243
+ previous_time_zone, Time.zone = Time.zone, "UTC"
1244
+ expected = %{<input id="post_written_on" name="post[written_on]" type="month" value="2004-06" />}
1245
+ @post.written_on = Time.zone.parse("2004-06-15 15:30:45")
1246
+ assert_dom_equal(expected, month_field("post", "written_on"))
1247
+ ensure
1248
+ Time.zone = previous_time_zone
1249
+ end
1250
+
1251
+ def test_week_field
1252
+ expected = %{<input id="post_written_on" name="post[written_on]" type="week" value="2004-W25" />}
1253
+ assert_dom_equal(expected, week_field("post", "written_on"))
1254
+ end
1255
+
1256
+ def test_week_field_with_nil_value
1257
+ expected = %{<input id="post_written_on" name="post[written_on]" type="week" />}
1258
+ @post.written_on = nil
1259
+ assert_dom_equal(expected, week_field("post", "written_on"))
1260
+ end
1261
+
1262
+ def test_week_field_with_datetime_value
1263
+ expected = %{<input id="post_written_on" name="post[written_on]" type="week" value="2004-W25" />}
1264
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1265
+ assert_dom_equal(expected, week_field("post", "written_on"))
1266
+ end
1267
+
1268
+ def test_week_field_with_extra_attrs
1269
+ expected = %{<input id="post_written_on" step="2" max="2010-W51" min="2000-W06" name="post[written_on]" type="week" value="2004-W25" />}
1270
+ @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3)
1271
+ min_value = DateTime.new(2000, 2, 13)
1272
+ max_value = DateTime.new(2010, 12, 23)
1273
+ step = 2
1274
+ assert_dom_equal(expected, week_field("post", "written_on", min: min_value, max: max_value, step: step))
1275
+ end
1276
+
1277
+ def test_week_field_with_timewithzone_value
1278
+ previous_time_zone, Time.zone = Time.zone, "UTC"
1279
+ expected = %{<input id="post_written_on" name="post[written_on]" type="week" value="2004-W25" />}
1280
+ @post.written_on = Time.zone.parse("2004-06-15 15:30:45")
1281
+ assert_dom_equal(expected, week_field("post", "written_on"))
1282
+ ensure
1283
+ Time.zone = previous_time_zone
1284
+ end
1285
+
1286
+ def test_week_field_week_number_base
1287
+ expected = %{<input id="post_written_on" name="post[written_on]" type="week" value="2015-W01" />}
1288
+ @post.written_on = DateTime.new(2015, 1, 1, 1, 2, 3)
1289
+ assert_dom_equal(expected, week_field("post", "written_on"))
1290
+ end
1291
+
1292
+ def test_url_field
1293
+ expected = %{<input id="user_homepage" name="user[homepage]" type="url" />}
1294
+ assert_dom_equal(expected, url_field("user", "homepage"))
1295
+ end
1296
+
1297
+ def test_email_field
1298
+ expected = %{<input id="user_address" name="user[address]" type="email" />}
1299
+ assert_dom_equal(expected, email_field("user", "address"))
1300
+ end
1301
+
1302
+ def test_number_field
1303
+ expected = %{<input name="order[quantity]" max="9" id="order_quantity" type="number" min="1" />}
1304
+ assert_dom_equal(expected, number_field("order", "quantity", in: 1...10))
1305
+ expected = %{<input name="order[quantity]" size="30" max="9" id="order_quantity" type="number" min="1" />}
1306
+ assert_dom_equal(expected, number_field("order", "quantity", size: 30, in: 1...10))
1307
+ end
1308
+
1309
+ def test_range_input
1310
+ expected = %{<input name="hifi[volume]" step="0.1" max="11" id="hifi_volume" type="range" min="0" />}
1311
+ assert_dom_equal(expected, range_field("hifi", "volume", in: 0..11, step: 0.1))
1312
+ expected = %{<input name="hifi[volume]" step="0.1" size="30" max="11" id="hifi_volume" type="range" min="0" />}
1313
+ assert_dom_equal(expected, range_field("hifi", "volume", size: 30, in: 0..11, step: 0.1))
1314
+ end
1315
+
1316
+ def test_explicit_name
1317
+ assert_dom_equal(
1318
+ '<input id="post_title" name="dont guess" type="text" value="Hello World" />',
1319
+ text_field("post", "title", "name" => "dont guess")
1320
+ )
1321
+ assert_dom_equal(
1322
+ %{<textarea id="post_body" name="really!">\nBack to the hill and over it again!</textarea>},
1323
+ text_area("post", "body", "name" => "really!")
1324
+ )
1325
+ assert_dom_equal(
1326
+ '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />',
1327
+ check_box("post", "secret", "name" => "i mean it")
1328
+ )
1329
+ assert_dom_equal(
1330
+ text_field("post", "title", "name" => "dont guess"),
1331
+ text_field("post", "title", name: "dont guess")
1332
+ )
1333
+ assert_dom_equal(
1334
+ text_area("post", "body", "name" => "really!"),
1335
+ text_area("post", "body", name: "really!")
1336
+ )
1337
+ assert_dom_equal(
1338
+ check_box("post", "secret", "name" => "i mean it"),
1339
+ check_box("post", "secret", name: "i mean it")
1340
+ )
1341
+ end
1342
+
1343
+ def test_explicit_id
1344
+ assert_dom_equal(
1345
+ '<input id="dont guess" name="post[title]" type="text" value="Hello World" />',
1346
+ text_field("post", "title", "id" => "dont guess")
1347
+ )
1348
+ assert_dom_equal(
1349
+ %{<textarea id="really!" name="post[body]">\nBack to the hill and over it again!</textarea>},
1350
+ text_area("post", "body", "id" => "really!")
1351
+ )
1352
+ assert_dom_equal(
1353
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />',
1354
+ check_box("post", "secret", "id" => "i mean it")
1355
+ )
1356
+ assert_dom_equal(
1357
+ text_field("post", "title", "id" => "dont guess"),
1358
+ text_field("post", "title", id: "dont guess")
1359
+ )
1360
+ assert_dom_equal(
1361
+ text_area("post", "body", "id" => "really!"),
1362
+ text_area("post", "body", id: "really!")
1363
+ )
1364
+ assert_dom_equal(
1365
+ check_box("post", "secret", "id" => "i mean it"),
1366
+ check_box("post", "secret", id: "i mean it")
1367
+ )
1368
+ end
1369
+
1370
+ def test_nil_id
1371
+ assert_dom_equal(
1372
+ '<input name="post[title]" type="text" value="Hello World" />',
1373
+ text_field("post", "title", "id" => nil)
1374
+ )
1375
+ assert_dom_equal(
1376
+ %{<textarea name="post[body]">\nBack to the hill and over it again!</textarea>},
1377
+ text_area("post", "body", "id" => nil)
1378
+ )
1379
+ assert_dom_equal(
1380
+ '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" name="post[secret]" type="checkbox" value="1" />',
1381
+ check_box("post", "secret", "id" => nil)
1382
+ )
1383
+ assert_dom_equal(
1384
+ '<input type="radio" name="post[secret]" value="0" />',
1385
+ radio_button("post", "secret", "0", "id" => nil)
1386
+ )
1387
+ assert_dom_equal(
1388
+ '<select name="post[secret]"></select>',
1389
+ select("post", "secret", [], {}, { "id" => nil })
1390
+ )
1391
+ assert_dom_equal(
1392
+ text_field("post", "title", "id" => nil),
1393
+ text_field("post", "title", id: nil)
1394
+ )
1395
+ assert_dom_equal(
1396
+ text_area("post", "body", "id" => nil),
1397
+ text_area("post", "body", id: nil)
1398
+ )
1399
+ assert_dom_equal(
1400
+ check_box("post", "secret", "id" => nil),
1401
+ check_box("post", "secret", id: nil)
1402
+ )
1403
+ assert_dom_equal(
1404
+ radio_button("post", "secret", "0", "id" => nil),
1405
+ radio_button("post", "secret", "0", id: nil)
1406
+ )
1407
+ end
1408
+
1409
+ def test_index
1410
+ assert_dom_equal(
1411
+ '<input name="post[5][title]" id="post_5_title" type="text" value="Hello World" />',
1412
+ text_field("post", "title", "index" => 5)
1413
+ )
1414
+ assert_dom_equal(
1415
+ %{<textarea name="post[5][body]" id="post_5_body">\nBack to the hill and over it again!</textarea>},
1416
+ text_area("post", "body", "index" => 5)
1417
+ )
1418
+ assert_dom_equal(
1419
+ '<input name="post[5][secret]" type="hidden" value="0" /><input checked="checked" name="post[5][secret]" type="checkbox" value="1" id="post_5_secret" />',
1420
+ check_box("post", "secret", "index" => 5)
1421
+ )
1422
+ assert_dom_equal(
1423
+ text_field("post", "title", "index" => 5),
1424
+ text_field("post", "title", "index" => 5)
1425
+ )
1426
+ assert_dom_equal(
1427
+ text_area("post", "body", "index" => 5),
1428
+ text_area("post", "body", "index" => 5)
1429
+ )
1430
+ assert_dom_equal(
1431
+ check_box("post", "secret", "index" => 5),
1432
+ check_box("post", "secret", "index" => 5)
1433
+ )
1434
+ end
1435
+
1436
+ def test_index_with_nil_id
1437
+ assert_dom_equal(
1438
+ '<input name="post[5][title]" type="text" value="Hello World" />',
1439
+ text_field("post", "title", "index" => 5, "id" => nil)
1440
+ )
1441
+ assert_dom_equal(
1442
+ %{<textarea name="post[5][body]">\nBack to the hill and over it again!</textarea>},
1443
+ text_area("post", "body", "index" => 5, "id" => nil)
1444
+ )
1445
+ assert_dom_equal(
1446
+ '<input name="post[5][secret]" type="hidden" value="0" /><input checked="checked" name="post[5][secret]" type="checkbox" value="1" />',
1447
+ check_box("post", "secret", "index" => 5, "id" => nil)
1448
+ )
1449
+ assert_dom_equal(
1450
+ text_field("post", "title", "index" => 5, "id" => nil),
1451
+ text_field("post", "title", index: 5, id: nil)
1452
+ )
1453
+ assert_dom_equal(
1454
+ text_area("post", "body", "index" => 5, "id" => nil),
1455
+ text_area("post", "body", index: 5, id: nil)
1456
+ )
1457
+ assert_dom_equal(
1458
+ check_box("post", "secret", "index" => 5, "id" => nil),
1459
+ check_box("post", "secret", index: 5, id: nil)
1460
+ )
1461
+ end
1462
+
1463
+ def test_auto_index
1464
+ pid = 123
1465
+ assert_dom_equal(
1466
+ %{<label for="post_#{pid}_title">Title</label>},
1467
+ label("post[]", "title")
1468
+ )
1469
+ assert_dom_equal(
1470
+ %{<input id="post_#{pid}_title" name="post[#{pid}][title]" type="text" value="Hello World" />},
1471
+ text_field("post[]", "title")
1472
+ )
1473
+ assert_dom_equal(
1474
+ %{<textarea id="post_#{pid}_body" name="post[#{pid}][body]">\nBack to the hill and over it again!</textarea>},
1475
+ text_area("post[]", "body")
1476
+ )
1477
+ assert_dom_equal(
1478
+ %{<input name="post[#{pid}][secret]" type="hidden" value="0" /><input checked="checked" id="post_#{pid}_secret" name="post[#{pid}][secret]" type="checkbox" value="1" />},
1479
+ check_box("post[]", "secret")
1480
+ )
1481
+ assert_dom_equal(
1482
+ %{<input checked="checked" id="post_#{pid}_title_hello_world" name="post[#{pid}][title]" type="radio" value="Hello World" />},
1483
+ radio_button("post[]", "title", "Hello World")
1484
+ )
1485
+ assert_dom_equal(
1486
+ %{<input id="post_#{pid}_title_goodbye_world" name="post[#{pid}][title]" type="radio" value="Goodbye World" />},
1487
+ radio_button("post[]", "title", "Goodbye World")
1488
+ )
1489
+ end
1490
+
1491
+ def test_auto_index_with_nil_id
1492
+ pid = 123
1493
+ assert_dom_equal(
1494
+ %{<input name="post[#{pid}][title]" type="text" value="Hello World" />},
1495
+ text_field("post[]", "title", id: nil)
1496
+ )
1497
+ assert_dom_equal(
1498
+ %{<textarea name="post[#{pid}][body]">\nBack to the hill and over it again!</textarea>},
1499
+ text_area("post[]", "body", id: nil)
1500
+ )
1501
+ assert_dom_equal(
1502
+ %{<input name="post[#{pid}][secret]" type="hidden" value="0" /><input checked="checked" name="post[#{pid}][secret]" type="checkbox" value="1" />},
1503
+ check_box("post[]", "secret", id: nil)
1504
+ )
1505
+ assert_dom_equal(
1506
+ %{<input checked="checked" name="post[#{pid}][title]" type="radio" value="Hello World" />},
1507
+ radio_button("post[]", "title", "Hello World", id: nil)
1508
+ )
1509
+ assert_dom_equal(
1510
+ %{<input name="post[#{pid}][title]" type="radio" value="Goodbye World" />},
1511
+ radio_button("post[]", "title", "Goodbye World", id: nil)
1512
+ )
1513
+ end
1514
+
1515
+ def test_form_for_requires_block
1516
+ error = assert_raises(ArgumentError) do
1517
+ form_for(@post, html: { id: "create-post" })
1518
+ end
1519
+ assert_equal "Missing block", error.message
1520
+ end
1521
+
1522
+ def test_form_for_requires_arguments
1523
+ error = assert_raises(ArgumentError) do
1524
+ form_for(nil, html: { id: "create-post" }) do
1525
+ end
1526
+ end
1527
+ assert_equal "First argument in form cannot contain nil or be empty", error.message
1528
+
1529
+ error = assert_raises(ArgumentError) do
1530
+ form_for([nil, nil], html: { id: "create-post" }) do
1531
+ end
1532
+ end
1533
+ assert_equal "First argument in form cannot contain nil or be empty", error.message
1534
+ end
1535
+
1536
+ def test_form_for
1537
+ form_for(@post, html: { id: "create-post" }) do |f|
1538
+ concat f.label(:title) { "The Title" }
1539
+ concat f.text_field(:title)
1540
+ concat f.text_area(:body)
1541
+ concat f.check_box(:secret)
1542
+ concat f.submit("Create post")
1543
+ concat f.button("Create post")
1544
+ concat f.button {
1545
+ concat content_tag(:span, "Create post")
1546
+ }
1547
+ end
1548
+
1549
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
1550
+ "<label for='post_title'>The Title</label>" \
1551
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
1552
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
1553
+ "<input name='post[secret]' type='hidden' value='0' />" \
1554
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" \
1555
+ "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />" \
1556
+ "<button name='button' type='submit'>Create post</button>" \
1557
+ "<button name='button' type='submit'><span>Create post</span></button>"
1558
+ end
1559
+
1560
+ assert_dom_equal expected, output_buffer
1561
+ end
1562
+
1563
+ def test_form_for_is_not_affected_by_form_with_generates_ids
1564
+ old_value = ActionView::Helpers::FormHelper.form_with_generates_ids
1565
+ ActionView::Helpers::FormHelper.form_with_generates_ids = false
1566
+
1567
+ form_for(@post, html: { id: "create-post" }) do |f|
1568
+ concat f.label(:title) { "The Title" }
1569
+ concat f.text_field(:title)
1570
+ concat f.text_area(:body)
1571
+ concat f.check_box(:secret)
1572
+ concat f.submit("Create post")
1573
+ concat f.button("Create post")
1574
+ concat f.button {
1575
+ concat content_tag(:span, "Create post")
1576
+ }
1577
+ end
1578
+
1579
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
1580
+ "<label for='post_title'>The Title</label>" \
1581
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
1582
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
1583
+ "<input name='post[secret]' type='hidden' value='0' />" \
1584
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" \
1585
+ "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />" \
1586
+ "<button name='button' type='submit'>Create post</button>" \
1587
+ "<button name='button' type='submit'><span>Create post</span></button>"
1588
+ end
1589
+
1590
+ assert_dom_equal expected, output_buffer
1591
+ ensure
1592
+ ActionView::Helpers::FormHelper.form_with_generates_ids = old_value
1593
+ end
1594
+
1595
+ def test_form_for_with_collection_radio_buttons
1596
+ post = Post.new
1597
+ def post.active; false; end
1598
+ form_for(post) do |f|
1599
+ concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s)
1600
+ end
1601
+
1602
+ expected = whole_form("/posts", "new_post", "new_post") do
1603
+ "<input type='hidden' name='post[active]' value='' />" \
1604
+ "<input id='post_active_true' name='post[active]' type='radio' value='true' />" \
1605
+ "<label for='post_active_true'>true</label>" \
1606
+ "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" \
1607
+ "<label for='post_active_false'>false</label>"
1608
+ end
1609
+
1610
+ assert_dom_equal expected, output_buffer
1611
+ end
1612
+
1613
+ def test_form_for_with_collection_radio_buttons_with_custom_builder_block
1614
+ post = Post.new
1615
+ def post.active; false; end
1616
+
1617
+ form_for(post) do |f|
1618
+ rendered_radio_buttons = f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) do |b|
1619
+ b.label { b.radio_button + b.text }
1620
+ end
1621
+ concat rendered_radio_buttons
1622
+ end
1623
+
1624
+ expected = whole_form("/posts", "new_post", "new_post") do
1625
+ "<input type='hidden' name='post[active]' value='' />" \
1626
+ "<label for='post_active_true'>" \
1627
+ "<input id='post_active_true' name='post[active]' type='radio' value='true' />" \
1628
+ "true</label>" \
1629
+ "<label for='post_active_false'>" \
1630
+ "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" \
1631
+ "false</label>"
1632
+ end
1633
+
1634
+ assert_dom_equal expected, output_buffer
1635
+ end
1636
+
1637
+ def test_form_for_with_collection_radio_buttons_with_custom_builder_block_does_not_leak_the_template
1638
+ post = Post.new
1639
+ def post.active; false; end
1640
+ def post.id; 1; end
1641
+
1642
+ form_for(post) do |f|
1643
+ rendered_radio_buttons = f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) do |b|
1644
+ b.label { b.radio_button + b.text }
1645
+ end
1646
+ concat rendered_radio_buttons
1647
+ concat f.hidden_field :id
1648
+ end
1649
+
1650
+ expected = whole_form("/posts", "new_post_1", "new_post") do
1651
+ "<input type='hidden' name='post[active]' value='' />" \
1652
+ "<label for='post_active_true'>" \
1653
+ "<input id='post_active_true' name='post[active]' type='radio' value='true' />" \
1654
+ "true</label>" \
1655
+ "<label for='post_active_false'>" \
1656
+ "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" \
1657
+ "false</label>" \
1658
+ "<input id='post_id' name='post[id]' type='hidden' value='1' />"
1659
+ end
1660
+
1661
+ assert_dom_equal expected, output_buffer
1662
+ end
1663
+
1664
+ def test_form_with_namespace_and_with_collection_radio_buttons
1665
+ post = Post.new
1666
+ def post.active; false; end
1667
+
1668
+ form_for(post, namespace: "foo") do |f|
1669
+ concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s)
1670
+ end
1671
+
1672
+ expected = whole_form("/posts", "foo_new_post", "new_post") do
1673
+ "<input type='hidden' name='post[active]' value='' />" \
1674
+ "<input id='foo_post_active_true' name='post[active]' type='radio' value='true' />" \
1675
+ "<label for='foo_post_active_true'>true</label>" \
1676
+ "<input checked='checked' id='foo_post_active_false' name='post[active]' type='radio' value='false' />" \
1677
+ "<label for='foo_post_active_false'>false</label>"
1678
+ end
1679
+
1680
+ assert_dom_equal expected, output_buffer
1681
+ end
1682
+
1683
+ def test_form_with_index_and_with_collection_radio_buttons
1684
+ post = Post.new
1685
+ def post.active; false; end
1686
+
1687
+ form_for(post, index: "1") do |f|
1688
+ concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s)
1689
+ end
1690
+
1691
+ expected = whole_form("/posts", "new_post", "new_post") do
1692
+ "<input type='hidden' name='post[1][active]' value='' />" \
1693
+ "<input id='post_1_active_true' name='post[1][active]' type='radio' value='true' />" \
1694
+ "<label for='post_1_active_true'>true</label>" \
1695
+ "<input checked='checked' id='post_1_active_false' name='post[1][active]' type='radio' value='false' />" \
1696
+ "<label for='post_1_active_false'>false</label>"
1697
+ end
1698
+
1699
+ assert_dom_equal expected, output_buffer
1700
+ end
1701
+
1702
+ def test_form_for_with_collection_check_boxes
1703
+ post = Post.new
1704
+ def post.tag_ids; [1, 3]; end
1705
+ collection = (1..3).map { |i| [i, "Tag #{i}"] }
1706
+ form_for(post) do |f|
1707
+ concat f.collection_check_boxes(:tag_ids, collection, :first, :last)
1708
+ end
1709
+
1710
+ expected = whole_form("/posts", "new_post", "new_post") do
1711
+ "<input name='post[tag_ids][]' type='hidden' value='' />" \
1712
+ "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" \
1713
+ "<label for='post_tag_ids_1'>Tag 1</label>" \
1714
+ "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" \
1715
+ "<label for='post_tag_ids_2'>Tag 2</label>" \
1716
+ "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" \
1717
+ "<label for='post_tag_ids_3'>Tag 3</label>"
1718
+ end
1719
+
1720
+ assert_dom_equal expected, output_buffer
1721
+ end
1722
+
1723
+ def test_form_for_with_collection_check_boxes_with_custom_builder_block
1724
+ post = Post.new
1725
+ def post.tag_ids; [1, 3]; end
1726
+ collection = (1..3).map { |i| [i, "Tag #{i}"] }
1727
+ form_for(post) do |f|
1728
+ rendered_check_boxes = f.collection_check_boxes(:tag_ids, collection, :first, :last) do |b|
1729
+ b.label { b.check_box + b.text }
1730
+ end
1731
+ concat rendered_check_boxes
1732
+ end
1733
+
1734
+ expected = whole_form("/posts", "new_post", "new_post") do
1735
+ "<input name='post[tag_ids][]' type='hidden' value='' />" \
1736
+ "<label for='post_tag_ids_1'>" \
1737
+ "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" \
1738
+ "Tag 1</label>" \
1739
+ "<label for='post_tag_ids_2'>" \
1740
+ "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" \
1741
+ "Tag 2</label>" \
1742
+ "<label for='post_tag_ids_3'>" \
1743
+ "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" \
1744
+ "Tag 3</label>"
1745
+ end
1746
+
1747
+ assert_dom_equal expected, output_buffer
1748
+ end
1749
+
1750
+ def test_form_for_with_collection_check_boxes_with_custom_builder_block_does_not_leak_the_template
1751
+ post = Post.new
1752
+ def post.tag_ids; [1, 3]; end
1753
+ def post.id; 1; end
1754
+ collection = (1..3).map { |i| [i, "Tag #{i}"] }
1755
+
1756
+ form_for(post) do |f|
1757
+ rendered_check_boxes = f.collection_check_boxes(:tag_ids, collection, :first, :last) do |b|
1758
+ b.label { b.check_box + b.text }
1759
+ end
1760
+ concat rendered_check_boxes
1761
+ concat f.hidden_field :id
1762
+ end
1763
+
1764
+ expected = whole_form("/posts", "new_post_1", "new_post") do
1765
+ "<input name='post[tag_ids][]' type='hidden' value='' />" \
1766
+ "<label for='post_tag_ids_1'>" \
1767
+ "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" \
1768
+ "Tag 1</label>" \
1769
+ "<label for='post_tag_ids_2'>" \
1770
+ "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" \
1771
+ "Tag 2</label>" \
1772
+ "<label for='post_tag_ids_3'>" \
1773
+ "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" \
1774
+ "Tag 3</label>" \
1775
+ "<input id='post_id' name='post[id]' type='hidden' value='1' />"
1776
+ end
1777
+
1778
+ assert_dom_equal expected, output_buffer
1779
+ end
1780
+
1781
+ def test_form_with_namespace_and_with_collection_check_boxes
1782
+ post = Post.new
1783
+ def post.tag_ids; [1]; end
1784
+ collection = [[1, "Tag 1"]]
1785
+
1786
+ form_for(post, namespace: "foo") do |f|
1787
+ concat f.collection_check_boxes(:tag_ids, collection, :first, :last)
1788
+ end
1789
+
1790
+ expected = whole_form("/posts", "foo_new_post", "new_post") do
1791
+ "<input name='post[tag_ids][]' type='hidden' value='' />" \
1792
+ "<input checked='checked' id='foo_post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" \
1793
+ "<label for='foo_post_tag_ids_1'>Tag 1</label>"
1794
+ end
1795
+
1796
+ assert_dom_equal expected, output_buffer
1797
+ end
1798
+
1799
+ def test_form_with_index_and_with_collection_check_boxes
1800
+ post = Post.new
1801
+ def post.tag_ids; [1]; end
1802
+ collection = [[1, "Tag 1"]]
1803
+
1804
+ form_for(post, index: "1") do |f|
1805
+ concat f.collection_check_boxes(:tag_ids, collection, :first, :last)
1806
+ end
1807
+
1808
+ expected = whole_form("/posts", "new_post", "new_post") do
1809
+ "<input name='post[1][tag_ids][]' type='hidden' value='' />" \
1810
+ "<input checked='checked' id='post_1_tag_ids_1' name='post[1][tag_ids][]' type='checkbox' value='1' />" \
1811
+ "<label for='post_1_tag_ids_1'>Tag 1</label>"
1812
+ end
1813
+
1814
+ assert_dom_equal expected, output_buffer
1815
+ end
1816
+
1817
+ def test_form_for_with_file_field_generate_multipart
1818
+ form_for(@post, html: { id: "create-post" }) do |f|
1819
+ concat f.file_field(:file)
1820
+ end
1821
+
1822
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch", multipart: true) do
1823
+ "<input name='post[file]' type='file' id='post_file' />"
1824
+ end
1825
+
1826
+ assert_dom_equal expected, output_buffer
1827
+ end
1828
+
1829
+ def test_fields_for_with_file_field_generate_multipart
1830
+ form_for(@post) do |f|
1831
+ concat f.fields_for(:comment, @post) { |c|
1832
+ concat c.file_field(:file)
1833
+ }
1834
+ end
1835
+
1836
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch", multipart: true) do
1837
+ "<input name='post[comment][file]' type='file' id='post_comment_file' />"
1838
+ end
1839
+
1840
+ assert_dom_equal expected, output_buffer
1841
+ end
1842
+
1843
+ def test_form_for_with_format
1844
+ form_for(@post, format: :json, html: { id: "edit_post_123", class: "edit_post" }) do |f|
1845
+ concat f.label(:title)
1846
+ end
1847
+
1848
+ expected = whole_form("/posts/123.json", "edit_post_123", "edit_post", method: "patch") do
1849
+ "<label for='post_title'>Title</label>"
1850
+ end
1851
+
1852
+ assert_dom_equal expected, output_buffer
1853
+ end
1854
+
1855
+ def test_form_for_with_model_using_relative_model_naming
1856
+ blog_post = Blog::Post.new("And his name will be forty and four.", 44)
1857
+
1858
+ form_for(blog_post) do |f|
1859
+ concat f.text_field :title
1860
+ concat f.submit("Edit post")
1861
+ end
1862
+
1863
+ expected = whole_form("/posts/44", "edit_post_44", "edit_post", method: "patch") do
1864
+ "<input name='post[title]' type='text' id='post_title' value='And his name will be forty and four.' />" \
1865
+ "<input name='commit' data-disable-with='Edit post' type='submit' value='Edit post' />"
1866
+ end
1867
+
1868
+ assert_dom_equal expected, output_buffer
1869
+ end
1870
+
1871
+ def test_form_for_with_symbol_as
1872
+ form_for(@post, as: "other_name", html: { id: "create-post" }) do |f|
1873
+ concat f.label(:title, class: "post_title")
1874
+ concat f.text_field(:title)
1875
+ concat f.text_area(:body)
1876
+ concat f.check_box(:secret)
1877
+ concat f.submit("Create post")
1878
+ end
1879
+
1880
+ expected = whole_form("/posts/123", "create-post", "edit_other_name", method: "patch") do
1881
+ "<label for='other_name_title' class='post_title'>Title</label>" \
1882
+ "<input name='other_name[title]' id='other_name_title' value='Hello World' type='text' />" \
1883
+ "<textarea name='other_name[body]' id='other_name_body'>\nBack to the hill and over it again!</textarea>" \
1884
+ "<input name='other_name[secret]' value='0' type='hidden' />" \
1885
+ "<input name='other_name[secret]' checked='checked' id='other_name_secret' value='1' type='checkbox' />" \
1886
+ "<input name='commit' value='Create post' data-disable-with='Create post' type='submit' />"
1887
+ end
1888
+
1889
+ assert_dom_equal expected, output_buffer
1890
+ end
1891
+
1892
+ def test_form_tags_do_not_call_private_properties_on_form_object
1893
+ obj = Class.new do
1894
+ private
1895
+
1896
+ def private_property
1897
+ raise "This method should not be called."
1898
+ end
1899
+ end.new
1900
+
1901
+ form_for(obj, as: "other_name", url: "/", html: { id: "edit-other-name" }) do |f|
1902
+ assert_raise(NoMethodError) { f.hidden_field(:private_property) }
1903
+ end
1904
+ end
1905
+
1906
+ def test_form_for_with_method_as_part_of_html_options
1907
+ form_for(@post, url: "/", html: { id: "create-post", method: :delete }) do |f|
1908
+ concat f.text_field(:title)
1909
+ concat f.text_area(:body)
1910
+ concat f.check_box(:secret)
1911
+ end
1912
+
1913
+ expected = whole_form("/", "create-post", "edit_post", method: "delete") do
1914
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
1915
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
1916
+ "<input name='post[secret]' type='hidden' value='0' />" \
1917
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
1918
+ end
1919
+
1920
+ assert_dom_equal expected, output_buffer
1921
+ end
1922
+
1923
+ def test_form_for_with_method
1924
+ form_for(@post, url: "/", method: :delete, html: { id: "create-post" }) do |f|
1925
+ concat f.text_field(:title)
1926
+ concat f.text_area(:body)
1927
+ concat f.check_box(:secret)
1928
+ end
1929
+
1930
+ expected = whole_form("/", "create-post", "edit_post", method: "delete") do
1931
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
1932
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
1933
+ "<input name='post[secret]' type='hidden' value='0' />" \
1934
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
1935
+ end
1936
+
1937
+ assert_dom_equal expected, output_buffer
1938
+ end
1939
+
1940
+ def test_form_for_with_search_field
1941
+ # Test case for bug which would emit an "object" attribute
1942
+ # when used with form_for using a search_field form helper
1943
+ form_for(Post.new, url: "/search", html: { id: "search-post", method: :get }) do |f|
1944
+ concat f.search_field(:title)
1945
+ end
1946
+
1947
+ expected = whole_form("/search", "search-post", "new_post", method: "get") do
1948
+ "<input name='post[title]' type='search' id='post_title' />"
1949
+ end
1950
+
1951
+ assert_dom_equal expected, output_buffer
1952
+ end
1953
+
1954
+ def test_form_for_with_remote
1955
+ form_for(@post, url: "/", remote: true, html: { id: "create-post", method: :patch }) do |f|
1956
+ concat f.text_field(:title)
1957
+ concat f.text_area(:body)
1958
+ concat f.check_box(:secret)
1959
+ end
1960
+
1961
+ expected = whole_form("/", "create-post", "edit_post", method: "patch", remote: true) do
1962
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
1963
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
1964
+ "<input name='post[secret]' type='hidden' value='0' />" \
1965
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
1966
+ end
1967
+
1968
+ assert_dom_equal expected, output_buffer
1969
+ end
1970
+
1971
+ def test_form_for_enforce_utf8_true
1972
+ form_for(:post, enforce_utf8: true) do |f|
1973
+ concat f.text_field(:title)
1974
+ end
1975
+
1976
+ expected = whole_form("/", nil, nil, enforce_utf8: true) do
1977
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />"
1978
+ end
1979
+
1980
+ assert_dom_equal expected, output_buffer
1981
+ end
1982
+
1983
+ def test_form_for_enforce_utf8_false
1984
+ form_for(:post, enforce_utf8: false) do |f|
1985
+ concat f.text_field(:title)
1986
+ end
1987
+
1988
+ expected = whole_form("/", nil, nil, enforce_utf8: false) do
1989
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />"
1990
+ end
1991
+
1992
+ assert_dom_equal expected, output_buffer
1993
+ end
1994
+
1995
+ def test_form_for_with_remote_in_html
1996
+ form_for(@post, url: "/", html: { remote: true, id: "create-post", method: :patch }) do |f|
1997
+ concat f.text_field(:title)
1998
+ concat f.text_area(:body)
1999
+ concat f.check_box(:secret)
2000
+ end
2001
+
2002
+ expected = whole_form("/", "create-post", "edit_post", method: "patch", remote: true) do
2003
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
2004
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
2005
+ "<input name='post[secret]' type='hidden' value='0' />" \
2006
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
2007
+ end
2008
+
2009
+ assert_dom_equal expected, output_buffer
2010
+ end
2011
+
2012
+ def test_form_for_with_remote_without_html
2013
+ @post.persisted = false
2014
+ @post.stub(:to_key, nil) do
2015
+ form_for(@post, remote: true) do |f|
2016
+ concat f.text_field(:title)
2017
+ concat f.text_area(:body)
2018
+ concat f.check_box(:secret)
2019
+ end
2020
+
2021
+ expected = whole_form("/posts", "new_post", "new_post", remote: true) do
2022
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
2023
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
2024
+ "<input name='post[secret]' type='hidden' value='0' />" \
2025
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
2026
+ end
2027
+
2028
+ assert_dom_equal expected, output_buffer
2029
+ end
2030
+ end
2031
+
2032
+ def test_form_for_without_object
2033
+ form_for(:post, html: { id: "create-post" }) do |f|
2034
+ concat f.text_field(:title)
2035
+ concat f.text_area(:body)
2036
+ concat f.check_box(:secret)
2037
+ end
2038
+
2039
+ expected = whole_form("/", "create-post") do
2040
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
2041
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
2042
+ "<input name='post[secret]' type='hidden' value='0' />" \
2043
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
2044
+ end
2045
+
2046
+ assert_dom_equal expected, output_buffer
2047
+ end
2048
+
2049
+ def test_form_for_with_index
2050
+ form_for(@post, as: "post[]") do |f|
2051
+ concat f.label(:title)
2052
+ concat f.text_field(:title)
2053
+ concat f.text_area(:body)
2054
+ concat f.check_box(:secret)
2055
+ end
2056
+
2057
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2058
+ "<label for='post_123_title'>Title</label>" \
2059
+ "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" \
2060
+ "<textarea name='post[123][body]' id='post_123_body'>\nBack to the hill and over it again!</textarea>" \
2061
+ "<input name='post[123][secret]' type='hidden' value='0' />" \
2062
+ "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"
2063
+ end
2064
+
2065
+ assert_dom_equal expected, output_buffer
2066
+ end
2067
+
2068
+ def test_form_for_with_nil_index_option_override
2069
+ form_for(@post, as: "post[]", index: nil) do |f|
2070
+ concat f.text_field(:title)
2071
+ concat f.text_area(:body)
2072
+ concat f.check_box(:secret)
2073
+ end
2074
+
2075
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2076
+ "<input name='post[][title]' type='text' id='post__title' value='Hello World' />" \
2077
+ "<textarea name='post[][body]' id='post__body'>\nBack to the hill and over it again!</textarea>" \
2078
+ "<input name='post[][secret]' type='hidden' value='0' />" \
2079
+ "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"
2080
+ end
2081
+
2082
+ assert_dom_equal expected, output_buffer
2083
+ end
2084
+
2085
+ def test_form_for_label_error_wrapping
2086
+ form_for(@post) do |f|
2087
+ concat f.label(:author_name, class: "label")
2088
+ concat f.text_field(:author_name)
2089
+ concat f.submit("Create post")
2090
+ end
2091
+
2092
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2093
+ "<div class='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" \
2094
+ "<div class='field_with_errors'><input name='post[author_name]' type='text' id='post_author_name' value='' /></div>" \
2095
+ "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />"
2096
+ end
2097
+
2098
+ assert_dom_equal expected, output_buffer
2099
+ end
2100
+
2101
+ def test_form_for_label_error_wrapping_without_conventional_instance_variable
2102
+ post = remove_instance_variable :@post
2103
+
2104
+ form_for(post) do |f|
2105
+ concat f.label(:author_name, class: "label")
2106
+ concat f.text_field(:author_name)
2107
+ concat f.submit("Create post")
2108
+ end
2109
+
2110
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2111
+ "<div class='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" \
2112
+ "<div class='field_with_errors'><input name='post[author_name]' type='text' id='post_author_name' value='' /></div>" \
2113
+ "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />"
2114
+ end
2115
+
2116
+ assert_dom_equal expected, output_buffer
2117
+ end
2118
+
2119
+ def test_form_for_label_error_wrapping_block_and_non_block_versions
2120
+ form_for(@post) do |f|
2121
+ concat f.label(:author_name, "Name", class: "label")
2122
+ concat f.label(:author_name, class: "label") { "Name" }
2123
+ end
2124
+
2125
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2126
+ "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>" \
2127
+ "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>"
2128
+ end
2129
+
2130
+ assert_dom_equal expected, output_buffer
2131
+ end
2132
+
2133
+ def test_form_for_with_namespace
2134
+ form_for(@post, namespace: "namespace") do |f|
2135
+ concat f.text_field(:title)
2136
+ concat f.text_area(:body)
2137
+ concat f.check_box(:secret)
2138
+ end
2139
+
2140
+ expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do
2141
+ "<input name='post[title]' type='text' id='namespace_post_title' value='Hello World' />" \
2142
+ "<textarea name='post[body]' id='namespace_post_body'>\nBack to the hill and over it again!</textarea>" \
2143
+ "<input name='post[secret]' type='hidden' value='0' />" \
2144
+ "<input name='post[secret]' checked='checked' type='checkbox' id='namespace_post_secret' value='1' />"
2145
+ end
2146
+
2147
+ assert_dom_equal expected, output_buffer
2148
+ end
2149
+
2150
+ def test_form_for_with_namespace_with_date_select
2151
+ form_for(@post, namespace: "namespace") do |f|
2152
+ concat f.date_select(:written_on)
2153
+ end
2154
+
2155
+ assert_select "select#namespace_post_written_on_1i"
2156
+ end
2157
+
2158
+ def test_form_for_with_namespace_with_label
2159
+ form_for(@post, namespace: "namespace") do |f|
2160
+ concat f.label(:title)
2161
+ concat f.text_field(:title)
2162
+ end
2163
+
2164
+ expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do
2165
+ "<label for='namespace_post_title'>Title</label>" \
2166
+ "<input name='post[title]' type='text' id='namespace_post_title' value='Hello World' />"
2167
+ end
2168
+
2169
+ assert_dom_equal expected, output_buffer
2170
+ end
2171
+
2172
+ def test_form_for_with_namespace_and_as_option
2173
+ form_for(@post, namespace: "namespace", as: "custom_name") do |f|
2174
+ concat f.text_field(:title)
2175
+ end
2176
+
2177
+ expected = whole_form("/posts/123", "namespace_edit_custom_name", "edit_custom_name", method: "patch") do
2178
+ "<input id='namespace_custom_name_title' name='custom_name[title]' type='text' value='Hello World' />"
2179
+ end
2180
+
2181
+ assert_dom_equal expected, output_buffer
2182
+ end
2183
+
2184
+ def test_two_form_for_with_namespace
2185
+ form_for(@post, namespace: "namespace_1") do |f|
2186
+ concat f.label(:title)
2187
+ concat f.text_field(:title)
2188
+ end
2189
+
2190
+ expected_1 = whole_form("/posts/123", "namespace_1_edit_post_123", "edit_post", method: "patch") do
2191
+ "<label for='namespace_1_post_title'>Title</label>" \
2192
+ "<input name='post[title]' type='text' id='namespace_1_post_title' value='Hello World' />"
2193
+ end
2194
+
2195
+ assert_dom_equal expected_1, output_buffer
2196
+
2197
+ form_for(@post, namespace: "namespace_2") do |f|
2198
+ concat f.label(:title)
2199
+ concat f.text_field(:title)
2200
+ end
2201
+
2202
+ expected_2 = whole_form("/posts/123", "namespace_2_edit_post_123", "edit_post", method: "patch") do
2203
+ "<label for='namespace_2_post_title'>Title</label>" \
2204
+ "<input name='post[title]' type='text' id='namespace_2_post_title' value='Hello World' />"
2205
+ end
2206
+
2207
+ assert_dom_equal expected_2, output_buffer
2208
+ end
2209
+
2210
+ def test_fields_for_with_namespace
2211
+ @comment.body = "Hello World"
2212
+ form_for(@post, namespace: "namespace") do |f|
2213
+ concat f.text_field(:title)
2214
+ concat f.text_area(:body)
2215
+ concat f.fields_for(@comment) { |c|
2216
+ concat c.text_field(:body)
2217
+ }
2218
+ end
2219
+
2220
+ expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do
2221
+ "<input name='post[title]' type='text' id='namespace_post_title' value='Hello World' />" \
2222
+ "<textarea name='post[body]' id='namespace_post_body'>\nBack to the hill and over it again!</textarea>" \
2223
+ "<input name='post[comment][body]' type='text' id='namespace_post_comment_body' value='Hello World' />"
2224
+ end
2225
+
2226
+ assert_dom_equal expected, output_buffer
2227
+ end
2228
+
2229
+ def test_submit_with_object_as_new_record_and_locale_strings
2230
+ with_locale :submit do
2231
+ @post.persisted = false
2232
+ @post.stub(:to_key, nil) do
2233
+ form_for(@post) do |f|
2234
+ concat f.submit
2235
+ end
2236
+
2237
+ expected = whole_form("/posts", "new_post", "new_post") do
2238
+ "<input name='commit' data-disable-with='Create Post' type='submit' value='Create Post' />"
2239
+ end
2240
+
2241
+ assert_dom_equal expected, output_buffer
2242
+ end
2243
+ end
2244
+ end
2245
+
2246
+ def test_submit_with_object_as_existing_record_and_locale_strings
2247
+ with_locale :submit do
2248
+ form_for(@post) do |f|
2249
+ concat f.submit
2250
+ end
2251
+
2252
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2253
+ "<input name='commit' data-disable-with='Confirm Post changes' type='submit' value='Confirm Post changes' />"
2254
+ end
2255
+
2256
+ assert_dom_equal expected, output_buffer
2257
+ end
2258
+ end
2259
+
2260
+ def test_submit_without_object_and_locale_strings
2261
+ with_locale :submit do
2262
+ form_for(:post) do |f|
2263
+ concat f.submit class: "extra"
2264
+ end
2265
+
2266
+ expected = whole_form do
2267
+ "<input name='commit' class='extra' data-disable-with='Save changes' type='submit' value='Save changes' />"
2268
+ end
2269
+
2270
+ assert_dom_equal expected, output_buffer
2271
+ end
2272
+ end
2273
+
2274
+ def test_submit_with_object_and_nested_lookup
2275
+ with_locale :submit do
2276
+ form_for(@post, as: :another_post) do |f|
2277
+ concat f.submit
2278
+ end
2279
+
2280
+ expected = whole_form("/posts/123", "edit_another_post", "edit_another_post", method: "patch") do
2281
+ "<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />"
2282
+ end
2283
+
2284
+ assert_dom_equal expected, output_buffer
2285
+ end
2286
+ end
2287
+
2288
+ def test_nested_fields_for
2289
+ @comment.body = "Hello World"
2290
+ form_for(@post) do |f|
2291
+ concat f.fields_for(@comment) { |c|
2292
+ concat c.text_field(:body)
2293
+ }
2294
+ end
2295
+
2296
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2297
+ "<input name='post[comment][body]' type='text' id='post_comment_body' value='Hello World' />"
2298
+ end
2299
+
2300
+ assert_dom_equal expected, output_buffer
2301
+ end
2302
+
2303
+ def test_deep_nested_fields_for
2304
+ @comment.save
2305
+ form_for(:posts) do |f|
2306
+ f.fields_for("post[]", @post) do |f2|
2307
+ f2.text_field(:id)
2308
+ @post.comments.each do |comment|
2309
+ concat f2.fields_for("comment[]", comment) { |c|
2310
+ concat c.text_field(:name)
2311
+ }
2312
+ end
2313
+ end
2314
+ end
2315
+
2316
+ expected = whole_form do
2317
+ "<input name='posts[post][0][comment][1][name]' type='text' id='posts_post_0_comment_1_name' value='comment #1' />"
2318
+ end
2319
+
2320
+ assert_dom_equal expected, output_buffer
2321
+ end
2322
+
2323
+ def test_nested_fields_for_with_nested_collections
2324
+ form_for(@post, as: "post[]") do |f|
2325
+ concat f.text_field(:title)
2326
+ concat f.fields_for("comment[]", @comment) { |c|
2327
+ concat c.text_field(:name)
2328
+ }
2329
+ concat f.text_field(:body)
2330
+ end
2331
+
2332
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2333
+ "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" \
2334
+ "<input name='post[123][comment][][name]' type='text' id='post_123_comment__name' value='new comment' />" \
2335
+ "<input name='post[123][body]' type='text' id='post_123_body' value='Back to the hill and over it again!' />"
2336
+ end
2337
+
2338
+ assert_dom_equal expected, output_buffer
2339
+ end
2340
+
2341
+ def test_nested_fields_for_with_index_and_parent_fields
2342
+ form_for(@post, index: 1) do |c|
2343
+ concat c.text_field(:title)
2344
+ concat c.fields_for("comment", @comment, index: 1) { |r|
2345
+ concat r.text_field(:name)
2346
+ }
2347
+ end
2348
+
2349
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2350
+ "<input name='post[1][title]' type='text' id='post_1_title' value='Hello World' />" \
2351
+ "<input name='post[1][comment][1][name]' type='text' id='post_1_comment_1_name' value='new comment' />"
2352
+ end
2353
+
2354
+ assert_dom_equal expected, output_buffer
2355
+ end
2356
+
2357
+ def test_form_for_with_index_and_nested_fields_for
2358
+ output_buffer = form_for(@post, index: 1) do |f|
2359
+ concat f.fields_for(:comment, @post) { |c|
2360
+ concat c.text_field(:title)
2361
+ }
2362
+ end
2363
+
2364
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2365
+ "<input name='post[1][comment][title]' type='text' id='post_1_comment_title' value='Hello World' />"
2366
+ end
2367
+
2368
+ assert_dom_equal expected, output_buffer
2369
+ end
2370
+
2371
+ def test_nested_fields_for_with_index_on_both
2372
+ form_for(@post, index: 1) do |f|
2373
+ concat f.fields_for(:comment, @post, index: 5) { |c|
2374
+ concat c.text_field(:title)
2375
+ }
2376
+ end
2377
+
2378
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2379
+ "<input name='post[1][comment][5][title]' type='text' id='post_1_comment_5_title' value='Hello World' />"
2380
+ end
2381
+
2382
+ assert_dom_equal expected, output_buffer
2383
+ end
2384
+
2385
+ def test_nested_fields_for_with_auto_index
2386
+ form_for(@post, as: "post[]") do |f|
2387
+ concat f.fields_for(:comment, @post) { |c|
2388
+ concat c.text_field(:title)
2389
+ }
2390
+ end
2391
+
2392
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2393
+ "<input name='post[123][comment][title]' type='text' id='post_123_comment_title' value='Hello World' />"
2394
+ end
2395
+
2396
+ assert_dom_equal expected, output_buffer
2397
+ end
2398
+
2399
+ def test_nested_fields_for_with_index_radio_button
2400
+ form_for(@post) do |f|
2401
+ concat f.fields_for(:comment, @post, index: 5) { |c|
2402
+ concat c.radio_button(:title, "hello")
2403
+ }
2404
+ end
2405
+
2406
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2407
+ "<input name='post[comment][5][title]' type='radio' id='post_comment_5_title_hello' value='hello' />"
2408
+ end
2409
+
2410
+ assert_dom_equal expected, output_buffer
2411
+ end
2412
+
2413
+ def test_nested_fields_for_with_auto_index_on_both
2414
+ form_for(@post, as: "post[]") do |f|
2415
+ concat f.fields_for("comment[]", @post) { |c|
2416
+ concat c.text_field(:title)
2417
+ }
2418
+ end
2419
+
2420
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2421
+ "<input name='post[123][comment][123][title]' type='text' id='post_123_comment_123_title' value='Hello World' />"
2422
+ end
2423
+
2424
+ assert_dom_equal expected, output_buffer
2425
+ end
2426
+
2427
+ def test_nested_fields_for_with_index_and_auto_index
2428
+ output_buffer = form_for(@post, as: "post[]") do |f|
2429
+ concat f.fields_for(:comment, @post, index: 5) { |c|
2430
+ concat c.text_field(:title)
2431
+ }
2432
+ end
2433
+
2434
+ output_buffer << form_for(@post, as: :post, index: 1) do |f|
2435
+ concat f.fields_for("comment[]", @post) { |c|
2436
+ concat c.text_field(:title)
2437
+ }
2438
+ end
2439
+
2440
+ expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
2441
+ "<input name='post[123][comment][5][title]' type='text' id='post_123_comment_5_title' value='Hello World' />"
2442
+ end + whole_form("/posts/123", "edit_post", "edit_post", method: "patch") do
2443
+ "<input name='post[1][comment][123][title]' type='text' id='post_1_comment_123_title' value='Hello World' />"
2444
+ end
2445
+
2446
+ assert_dom_equal expected, output_buffer
2447
+ end
2448
+
2449
+ def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association
2450
+ @post.author = Author.new
2451
+
2452
+ form_for(@post) do |f|
2453
+ concat f.text_field(:title)
2454
+ concat f.fields_for(:author) { |af|
2455
+ concat af.text_field(:name)
2456
+ }
2457
+ end
2458
+
2459
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2460
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2461
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="new author" />'
2462
+ end
2463
+
2464
+ assert_dom_equal expected, output_buffer
2465
+ end
2466
+
2467
+ def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association
2468
+ form_for(@post) do |f|
2469
+ f.fields_for(:author, Author.new(123)) do |af|
2470
+ assert_not_nil af.object
2471
+ assert_equal 123, af.object.id
2472
+ end
2473
+ end
2474
+ end
2475
+
2476
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association
2477
+ @post.author = Author.new(321)
2478
+
2479
+ form_for(@post) do |f|
2480
+ concat f.text_field(:title)
2481
+ concat f.fields_for(:author) { |af|
2482
+ concat af.text_field(:name)
2483
+ }
2484
+ end
2485
+
2486
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2487
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2488
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2489
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
2490
+ end
2491
+
2492
+ assert_dom_equal expected, output_buffer
2493
+ end
2494
+
2495
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_using_erb_and_inline_block
2496
+ @post.author = Author.new(321)
2497
+
2498
+ form_for(@post) do |f|
2499
+ concat f.text_field(:title)
2500
+ concat f.fields_for(:author) { |af|
2501
+ af.text_field(:name)
2502
+ }
2503
+ end
2504
+
2505
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2506
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2507
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2508
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
2509
+ end
2510
+
2511
+ assert_dom_equal expected, output_buffer
2512
+ end
2513
+
2514
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id
2515
+ @post.author = Author.new(321)
2516
+
2517
+ form_for(@post) do |f|
2518
+ concat f.text_field(:title)
2519
+ concat f.fields_for(:author, include_id: false) { |af|
2520
+ af.text_field(:name)
2521
+ }
2522
+ end
2523
+
2524
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2525
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2526
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
2527
+ end
2528
+
2529
+ assert_dom_equal expected, output_buffer
2530
+ end
2531
+
2532
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_inherited
2533
+ @post.author = Author.new(321)
2534
+
2535
+ form_for(@post, include_id: false) do |f|
2536
+ concat f.text_field(:title)
2537
+ concat f.fields_for(:author) { |af|
2538
+ af.text_field(:name)
2539
+ }
2540
+ end
2541
+
2542
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2543
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2544
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
2545
+ end
2546
+
2547
+ assert_dom_equal expected, output_buffer
2548
+ end
2549
+
2550
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_override
2551
+ @post.author = Author.new(321)
2552
+
2553
+ form_for(@post, include_id: false) do |f|
2554
+ concat f.text_field(:title)
2555
+ concat f.fields_for(:author, include_id: true) { |af|
2556
+ af.text_field(:name)
2557
+ }
2558
+ end
2559
+
2560
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2561
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2562
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2563
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
2564
+ end
2565
+
2566
+ assert_dom_equal expected, output_buffer
2567
+ end
2568
+
2569
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement
2570
+ @post.author = Author.new(321)
2571
+
2572
+ form_for(@post) do |f|
2573
+ concat f.text_field(:title)
2574
+ concat f.fields_for(:author) { |af|
2575
+ concat af.hidden_field(:id)
2576
+ concat af.text_field(:name)
2577
+ }
2578
+ end
2579
+
2580
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2581
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2582
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' \
2583
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
2584
+ end
2585
+
2586
+ assert_dom_equal expected, output_buffer
2587
+ end
2588
+
2589
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association
2590
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2591
+
2592
+ form_for(@post) do |f|
2593
+ concat f.text_field(:title)
2594
+ @post.comments.each do |comment|
2595
+ concat f.fields_for(:comments, comment) { |cf|
2596
+ concat cf.text_field(:name)
2597
+ }
2598
+ end
2599
+ end
2600
+
2601
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2602
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2603
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2604
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2605
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' \
2606
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
2607
+ end
2608
+
2609
+ assert_dom_equal expected, output_buffer
2610
+ end
2611
+
2612
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id
2613
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2614
+ @post.author = Author.new(321)
2615
+
2616
+ form_for(@post) do |f|
2617
+ concat f.text_field(:title)
2618
+ concat f.fields_for(:author) { |af|
2619
+ concat af.text_field(:name)
2620
+ }
2621
+ @post.comments.each do |comment|
2622
+ concat f.fields_for(:comments, comment, include_id: false) { |cf|
2623
+ concat cf.text_field(:name)
2624
+ }
2625
+ end
2626
+ end
2627
+
2628
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2629
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2630
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2631
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' \
2632
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2633
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
2634
+ end
2635
+
2636
+ assert_dom_equal expected, output_buffer
2637
+ end
2638
+
2639
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_inherited
2640
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2641
+ @post.author = Author.new(321)
2642
+
2643
+ form_for(@post, include_id: false) do |f|
2644
+ concat f.text_field(:title)
2645
+ concat f.fields_for(:author) { |af|
2646
+ concat af.text_field(:name)
2647
+ }
2648
+ @post.comments.each do |comment|
2649
+ concat f.fields_for(:comments, comment) { |cf|
2650
+ concat cf.text_field(:name)
2651
+ }
2652
+ end
2653
+ end
2654
+
2655
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2656
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2657
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2658
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2659
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
2660
+ end
2661
+
2662
+ assert_dom_equal expected, output_buffer
2663
+ end
2664
+
2665
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_override
2666
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2667
+ @post.author = Author.new(321)
2668
+
2669
+ form_for(@post, include_id: false) do |f|
2670
+ concat f.text_field(:title)
2671
+ concat f.fields_for(:author, include_id: true) { |af|
2672
+ concat af.text_field(:name)
2673
+ }
2674
+ @post.comments.each do |comment|
2675
+ concat f.fields_for(:comments, comment) { |cf|
2676
+ concat cf.text_field(:name)
2677
+ }
2678
+ end
2679
+ end
2680
+
2681
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2682
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2683
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' \
2684
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' \
2685
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2686
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
2687
+ end
2688
+
2689
+ assert_dom_equal expected, output_buffer
2690
+ end
2691
+
2692
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_using_erb_and_inline_block
2693
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2694
+
2695
+ form_for(@post) do |f|
2696
+ concat f.text_field(:title)
2697
+ @post.comments.each do |comment|
2698
+ concat f.fields_for(:comments, comment) { |cf|
2699
+ cf.text_field(:name)
2700
+ }
2701
+ end
2702
+ end
2703
+
2704
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2705
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2706
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2707
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2708
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' \
2709
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
2710
+ end
2711
+
2712
+ assert_dom_equal expected, output_buffer
2713
+ end
2714
+
2715
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_explicit_hidden_field_placement
2716
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2717
+
2718
+ form_for(@post) do |f|
2719
+ concat f.text_field(:title)
2720
+ @post.comments.each do |comment|
2721
+ concat f.fields_for(:comments, comment) { |cf|
2722
+ concat cf.hidden_field(:id)
2723
+ concat cf.text_field(:name)
2724
+ }
2725
+ end
2726
+ end
2727
+
2728
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2729
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2730
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2731
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2732
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' \
2733
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
2734
+ end
2735
+
2736
+ assert_dom_equal expected, output_buffer
2737
+ end
2738
+
2739
+ def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association
2740
+ @post.comments = [Comment.new, Comment.new]
2741
+
2742
+ form_for(@post) do |f|
2743
+ concat f.text_field(:title)
2744
+ @post.comments.each do |comment|
2745
+ concat f.fields_for(:comments, comment) { |cf|
2746
+ concat cf.text_field(:name)
2747
+ }
2748
+ end
2749
+ end
2750
+
2751
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2752
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2753
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="new comment" />' \
2754
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
2755
+ end
2756
+
2757
+ assert_dom_equal expected, output_buffer
2758
+ end
2759
+
2760
+ def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association
2761
+ @post.comments = [Comment.new(321), Comment.new]
2762
+
2763
+ form_for(@post) do |f|
2764
+ concat f.text_field(:title)
2765
+ @post.comments.each do |comment|
2766
+ concat f.fields_for(:comments, comment) { |cf|
2767
+ concat cf.text_field(:name)
2768
+ }
2769
+ end
2770
+ end
2771
+
2772
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2773
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2774
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' \
2775
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' \
2776
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
2777
+ end
2778
+
2779
+ assert_dom_equal expected, output_buffer
2780
+ end
2781
+
2782
+ def test_nested_fields_for_with_an_empty_supplied_attributes_collection
2783
+ form_for(@post) do |f|
2784
+ concat f.text_field(:title)
2785
+ f.fields_for(:comments, []) do |cf|
2786
+ concat cf.text_field(:name)
2787
+ end
2788
+ end
2789
+
2790
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2791
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />'
2792
+ end
2793
+
2794
+ assert_dom_equal expected, output_buffer
2795
+ end
2796
+
2797
+ def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection
2798
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2799
+
2800
+ form_for(@post) do |f|
2801
+ concat f.text_field(:title)
2802
+ concat f.fields_for(:comments, @post.comments) { |cf|
2803
+ concat cf.text_field(:name)
2804
+ }
2805
+ end
2806
+
2807
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2808
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2809
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2810
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2811
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' \
2812
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
2813
+ end
2814
+
2815
+ assert_dom_equal expected, output_buffer
2816
+ end
2817
+
2818
+ def test_nested_fields_for_arel_like
2819
+ @post.comments = ArelLike.new
2820
+
2821
+ form_for(@post) do |f|
2822
+ concat f.text_field(:title)
2823
+ concat f.fields_for(:comments, @post.comments) { |cf|
2824
+ concat cf.text_field(:name)
2825
+ }
2826
+ end
2827
+
2828
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2829
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2830
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2831
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2832
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' \
2833
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
2834
+ end
2835
+
2836
+ assert_dom_equal expected, output_buffer
2837
+ end
2838
+
2839
+ def test_nested_fields_label_translation_with_more_than_10_records
2840
+ @post.comments = Array.new(11) { |id| Comment.new(id + 1) }
2841
+
2842
+ params = 11.times.map { ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"] }
2843
+ assert_called_with(I18n, :t, params, returns: "Write body here") do
2844
+ form_for(@post) do |f|
2845
+ f.fields_for(:comments) do |cf|
2846
+ concat cf.label(:body)
2847
+ end
2848
+ end
2849
+ end
2850
+ end
2851
+
2852
+ def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
2853
+ comments = Array.new(2) { |id| Comment.new(id + 1) }
2854
+ @post.comments = []
2855
+
2856
+ form_for(@post) do |f|
2857
+ concat f.text_field(:title)
2858
+ concat f.fields_for(:comments, comments) { |cf|
2859
+ concat cf.text_field(:name)
2860
+ }
2861
+ end
2862
+
2863
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2864
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2865
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' \
2866
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' \
2867
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' \
2868
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
2869
+ end
2870
+
2871
+ assert_dom_equal expected, output_buffer
2872
+ end
2873
+
2874
+ def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder
2875
+ @post.comments = [Comment.new(321), Comment.new]
2876
+ yielded_comments = []
2877
+
2878
+ form_for(@post) do |f|
2879
+ concat f.text_field(:title)
2880
+ concat f.fields_for(:comments) { |cf|
2881
+ concat cf.text_field(:name)
2882
+ yielded_comments << cf.object
2883
+ }
2884
+ end
2885
+
2886
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2887
+ '<input name="post[title]" type="text" id="post_title" value="Hello World" />' \
2888
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' \
2889
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' \
2890
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
2891
+ end
2892
+
2893
+ assert_dom_equal expected, output_buffer
2894
+ assert_equal yielded_comments, @post.comments
2895
+ end
2896
+
2897
+ def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association
2898
+ @post.comments = []
2899
+
2900
+ form_for(@post) do |f|
2901
+ concat f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf|
2902
+ concat cf.text_field(:name)
2903
+ }
2904
+ end
2905
+
2906
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2907
+ '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' \
2908
+ '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
2909
+ end
2910
+
2911
+ assert_dom_equal expected, output_buffer
2912
+ end
2913
+
2914
+ def test_nested_fields_for_with_child_index_as_lambda_option_override_on_a_nested_attributes_collection_association
2915
+ @post.comments = []
2916
+
2917
+ form_for(@post) do |f|
2918
+ concat f.fields_for(:comments, Comment.new(321), child_index: -> { "abc" }) { |cf|
2919
+ concat cf.text_field(:name)
2920
+ }
2921
+ end
2922
+
2923
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2924
+ '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' \
2925
+ '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
2926
+ end
2927
+
2928
+ assert_dom_equal expected, output_buffer
2929
+ end
2930
+
2931
+ class FakeAssociationProxy
2932
+ def to_ary
2933
+ [1, 2, 3]
2934
+ end
2935
+ end
2936
+
2937
+ def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association_with_proxy
2938
+ @post.comments = FakeAssociationProxy.new
2939
+
2940
+ form_for(@post) do |f|
2941
+ concat f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf|
2942
+ concat cf.text_field(:name)
2943
+ }
2944
+ end
2945
+
2946
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
2947
+ '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' \
2948
+ '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
2949
+ end
2950
+
2951
+ assert_dom_equal expected, output_buffer
2952
+ end
2953
+
2954
+ def test_nested_fields_for_index_method_with_existing_records_on_a_nested_attributes_collection_association
2955
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2956
+
2957
+ form_for(@post) do |f|
2958
+ expected = 0
2959
+ @post.comments.each do |comment|
2960
+ f.fields_for(:comments, comment) { |cf|
2961
+ assert_equal expected, cf.index
2962
+ expected += 1
2963
+ }
2964
+ end
2965
+ end
2966
+ end
2967
+
2968
+ def test_nested_fields_for_index_method_with_existing_and_new_records_on_a_nested_attributes_collection_association
2969
+ @post.comments = [Comment.new(321), Comment.new]
2970
+
2971
+ form_for(@post) do |f|
2972
+ expected = 0
2973
+ @post.comments.each do |comment|
2974
+ f.fields_for(:comments, comment) { |cf|
2975
+ assert_equal expected, cf.index
2976
+ expected += 1
2977
+ }
2978
+ end
2979
+ end
2980
+ end
2981
+
2982
+ def test_nested_fields_for_index_method_with_existing_records_on_a_supplied_nested_attributes_collection
2983
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
2984
+
2985
+ form_for(@post) do |f|
2986
+ expected = 0
2987
+ f.fields_for(:comments, @post.comments) { |cf|
2988
+ assert_equal expected, cf.index
2989
+ expected += 1
2990
+ }
2991
+ end
2992
+ end
2993
+
2994
+ def test_nested_fields_for_index_method_with_child_index_option_override_on_a_nested_attributes_collection_association
2995
+ @post.comments = []
2996
+
2997
+ form_for(@post) do |f|
2998
+ f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf|
2999
+ assert_equal "abc", cf.index
3000
+ }
3001
+ end
3002
+ end
3003
+
3004
+ def test_nested_fields_uses_unique_indices_for_different_collection_associations
3005
+ @post.comments = [Comment.new(321)]
3006
+ @post.tags = [Tag.new(123), Tag.new(456)]
3007
+ @post.comments[0].relevances = []
3008
+ @post.tags[0].relevances = []
3009
+ @post.tags[1].relevances = []
3010
+
3011
+ form_for(@post) do |f|
3012
+ concat f.fields_for(:comments, @post.comments[0]) { |cf|
3013
+ concat cf.text_field(:name)
3014
+ concat cf.fields_for(:relevances, CommentRelevance.new(314)) { |crf|
3015
+ concat crf.text_field(:value)
3016
+ }
3017
+ }
3018
+ concat f.fields_for(:tags, @post.tags[0]) { |tf|
3019
+ concat tf.text_field(:value)
3020
+ concat tf.fields_for(:relevances, TagRelevance.new(3141)) { |trf|
3021
+ concat trf.text_field(:value)
3022
+ }
3023
+ }
3024
+ concat f.fields_for("tags", @post.tags[1]) { |tf|
3025
+ concat tf.text_field(:value)
3026
+ concat tf.fields_for(:relevances, TagRelevance.new(31415)) { |trf|
3027
+ concat trf.text_field(:value)
3028
+ }
3029
+ }
3030
+ end
3031
+
3032
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3033
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' \
3034
+ '<input id="post_comments_attributes_0_relevances_attributes_0_value" name="post[comments_attributes][0][relevances_attributes][0][value]" type="text" value="commentrelevance #314" />' \
3035
+ '<input id="post_comments_attributes_0_relevances_attributes_0_id" name="post[comments_attributes][0][relevances_attributes][0][id]" type="hidden" value="314" />' \
3036
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' \
3037
+ '<input id="post_tags_attributes_0_value" name="post[tags_attributes][0][value]" type="text" value="tag #123" />' \
3038
+ '<input id="post_tags_attributes_0_relevances_attributes_0_value" name="post[tags_attributes][0][relevances_attributes][0][value]" type="text" value="tagrelevance #3141" />' \
3039
+ '<input id="post_tags_attributes_0_relevances_attributes_0_id" name="post[tags_attributes][0][relevances_attributes][0][id]" type="hidden" value="3141" />' \
3040
+ '<input id="post_tags_attributes_0_id" name="post[tags_attributes][0][id]" type="hidden" value="123" />' \
3041
+ '<input id="post_tags_attributes_1_value" name="post[tags_attributes][1][value]" type="text" value="tag #456" />' \
3042
+ '<input id="post_tags_attributes_1_relevances_attributes_0_value" name="post[tags_attributes][1][relevances_attributes][0][value]" type="text" value="tagrelevance #31415" />' \
3043
+ '<input id="post_tags_attributes_1_relevances_attributes_0_id" name="post[tags_attributes][1][relevances_attributes][0][id]" type="hidden" value="31415" />' \
3044
+ '<input id="post_tags_attributes_1_id" name="post[tags_attributes][1][id]" type="hidden" value="456" />'
3045
+ end
3046
+
3047
+ assert_dom_equal expected, output_buffer
3048
+ end
3049
+
3050
+ def test_nested_fields_for_with_hash_like_model
3051
+ @author = HashBackedAuthor.new
3052
+
3053
+ form_for(@post) do |f|
3054
+ concat f.fields_for(:author, @author) { |af|
3055
+ concat af.text_field(:name)
3056
+ }
3057
+ end
3058
+
3059
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3060
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="hash backed author" />'
3061
+ end
3062
+
3063
+ assert_dom_equal expected, output_buffer
3064
+ end
3065
+
3066
+ def test_fields_for
3067
+ output_buffer = fields_for(:post, @post) do |f|
3068
+ concat f.text_field(:title)
3069
+ concat f.text_area(:body)
3070
+ concat f.check_box(:secret)
3071
+ end
3072
+
3073
+ expected =
3074
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
3075
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
3076
+ "<input name='post[secret]' type='hidden' value='0' />" \
3077
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
3078
+
3079
+ assert_dom_equal expected, output_buffer
3080
+ end
3081
+
3082
+ def test_fields_for_with_index
3083
+ output_buffer = fields_for("post[]", @post) do |f|
3084
+ concat f.text_field(:title)
3085
+ concat f.text_area(:body)
3086
+ concat f.check_box(:secret)
3087
+ end
3088
+
3089
+ expected =
3090
+ "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" \
3091
+ "<textarea name='post[123][body]' id='post_123_body'>\nBack to the hill and over it again!</textarea>" \
3092
+ "<input name='post[123][secret]' type='hidden' value='0' />" \
3093
+ "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"
3094
+
3095
+ assert_dom_equal expected, output_buffer
3096
+ end
3097
+
3098
+ def test_fields_for_with_nil_index_option_override
3099
+ output_buffer = fields_for("post[]", @post, index: nil) do |f|
3100
+ concat f.text_field(:title)
3101
+ concat f.text_area(:body)
3102
+ concat f.check_box(:secret)
3103
+ end
3104
+
3105
+ expected =
3106
+ "<input name='post[][title]' type='text' id='post__title' value='Hello World' />" \
3107
+ "<textarea name='post[][body]' id='post__body'>\nBack to the hill and over it again!</textarea>" \
3108
+ "<input name='post[][secret]' type='hidden' value='0' />" \
3109
+ "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"
3110
+
3111
+ assert_dom_equal expected, output_buffer
3112
+ end
3113
+
3114
+ def test_fields_for_with_index_option_override
3115
+ output_buffer = fields_for("post[]", @post, index: "abc") do |f|
3116
+ concat f.text_field(:title)
3117
+ concat f.text_area(:body)
3118
+ concat f.check_box(:secret)
3119
+ end
3120
+
3121
+ expected =
3122
+ "<input name='post[abc][title]' type='text' id='post_abc_title' value='Hello World' />" \
3123
+ "<textarea name='post[abc][body]' id='post_abc_body'>\nBack to the hill and over it again!</textarea>" \
3124
+ "<input name='post[abc][secret]' type='hidden' value='0' />" \
3125
+ "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />"
3126
+
3127
+ assert_dom_equal expected, output_buffer
3128
+ end
3129
+
3130
+ def test_fields_for_without_object
3131
+ output_buffer = fields_for(:post) do |f|
3132
+ concat f.text_field(:title)
3133
+ concat f.text_area(:body)
3134
+ concat f.check_box(:secret)
3135
+ end
3136
+
3137
+ expected =
3138
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
3139
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
3140
+ "<input name='post[secret]' type='hidden' value='0' />" \
3141
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
3142
+
3143
+ assert_dom_equal expected, output_buffer
3144
+ end
3145
+
3146
+ def test_fields_for_with_only_object
3147
+ output_buffer = fields_for(@post) do |f|
3148
+ concat f.text_field(:title)
3149
+ concat f.text_area(:body)
3150
+ concat f.check_box(:secret)
3151
+ end
3152
+
3153
+ expected =
3154
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
3155
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
3156
+ "<input name='post[secret]' type='hidden' value='0' />" \
3157
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
3158
+
3159
+ assert_dom_equal expected, output_buffer
3160
+ end
3161
+
3162
+ def test_fields_for_object_with_bracketed_name
3163
+ output_buffer = fields_for("author[post]", @post) do |f|
3164
+ concat f.label(:title)
3165
+ concat f.text_field(:title)
3166
+ end
3167
+
3168
+ assert_dom_equal "<label for=\"author_post_title\">Title</label>" \
3169
+ "<input name='author[post][title]' type='text' id='author_post_title' value='Hello World' />",
3170
+ output_buffer
3171
+ end
3172
+
3173
+ def test_fields_for_object_with_bracketed_name_and_index
3174
+ output_buffer = fields_for("author[post]", @post, index: 1) do |f|
3175
+ concat f.label(:title)
3176
+ concat f.text_field(:title)
3177
+ end
3178
+
3179
+ assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" \
3180
+ "<input name='author[post][1][title]' type='text' id='author_post_1_title' value='Hello World' />",
3181
+ output_buffer
3182
+ end
3183
+
3184
+ def test_form_builder_does_not_have_form_for_method
3185
+ assert_not_includes ActionView::Helpers::FormBuilder.instance_methods, :form_for
3186
+ end
3187
+
3188
+ def test_form_for_and_fields_for
3189
+ form_for(@post, as: :post, html: { id: "create-post" }) do |post_form|
3190
+ concat post_form.text_field(:title)
3191
+ concat post_form.text_area(:body)
3192
+
3193
+ concat fields_for(:parent_post, @post) { |parent_fields|
3194
+ concat parent_fields.check_box(:secret)
3195
+ }
3196
+ end
3197
+
3198
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
3199
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
3200
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
3201
+ "<input name='parent_post[secret]' type='hidden' value='0' />" \
3202
+ "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />"
3203
+ end
3204
+
3205
+ assert_dom_equal expected, output_buffer
3206
+ end
3207
+
3208
+ def test_form_for_and_fields_for_with_object
3209
+ form_for(@post, as: :post, html: { id: "create-post" }) do |post_form|
3210
+ concat post_form.text_field(:title)
3211
+ concat post_form.text_area(:body)
3212
+
3213
+ concat post_form.fields_for(@comment) { |comment_fields|
3214
+ concat comment_fields.text_field(:name)
3215
+ }
3216
+ end
3217
+
3218
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
3219
+ "<input name='post[title]' type='text' id='post_title' value='Hello World' />" \
3220
+ "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" \
3221
+ "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' />"
3222
+ end
3223
+
3224
+ assert_dom_equal expected, output_buffer
3225
+ end
3226
+
3227
+ def test_form_for_and_fields_for_with_non_nested_association_and_without_object
3228
+ form_for(@post) do |f|
3229
+ concat f.fields_for(:category) { |c|
3230
+ concat c.text_field(:name)
3231
+ }
3232
+ end
3233
+
3234
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3235
+ "<input name='post[category][name]' type='text' id='post_category_name' />"
3236
+ end
3237
+
3238
+ assert_dom_equal expected, output_buffer
3239
+ end
3240
+
3241
+ class LabelledFormBuilder < ActionView::Helpers::FormBuilder
3242
+ (field_helpers - %w(hidden_field)).each do |selector|
3243
+ class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
3244
+ def #{selector}(field, *args, &proc)
3245
+ ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
3246
+ end
3247
+ RUBY_EVAL
3248
+ end
3249
+ end
3250
+
3251
+ def test_form_for_with_labelled_builder
3252
+ form_for(@post, builder: LabelledFormBuilder) do |f|
3253
+ concat f.text_field(:title)
3254
+ concat f.text_area(:body)
3255
+ concat f.check_box(:secret)
3256
+ end
3257
+
3258
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3259
+ "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" \
3260
+ "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" \
3261
+ "<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/>"
3262
+ end
3263
+
3264
+ assert_dom_equal expected, output_buffer
3265
+ end
3266
+
3267
+ def test_default_form_builder
3268
+ old_default_form_builder, ActionView::Base.default_form_builder =
3269
+ ActionView::Base.default_form_builder, LabelledFormBuilder
3270
+
3271
+ form_for(@post) do |f|
3272
+ concat f.text_field(:title)
3273
+ concat f.text_area(:body)
3274
+ concat f.check_box(:secret)
3275
+ end
3276
+
3277
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3278
+ "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" \
3279
+ "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" \
3280
+ "<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/>"
3281
+ end
3282
+
3283
+ assert_dom_equal expected, output_buffer
3284
+ ensure
3285
+ ActionView::Base.default_form_builder = old_default_form_builder
3286
+ end
3287
+
3288
+ def test_lazy_loading_default_form_builder
3289
+ old_default_form_builder, ActionView::Base.default_form_builder =
3290
+ ActionView::Base.default_form_builder, "FormHelperTest::LabelledFormBuilder"
3291
+
3292
+ form_for(@post) do |f|
3293
+ concat f.text_field(:title)
3294
+ end
3295
+
3296
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
3297
+ "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
3298
+ end
3299
+
3300
+ assert_dom_equal expected, output_buffer
3301
+ ensure
3302
+ ActionView::Base.default_form_builder = old_default_form_builder
3303
+ end
3304
+
3305
+ def test_form_builder_override
3306
+ self.default_form_builder = LabelledFormBuilder
3307
+
3308
+ output_buffer = fields_for(:post, @post) do |f|
3309
+ concat f.text_field(:title)
3310
+ end
3311
+
3312
+ expected = "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
3313
+
3314
+ assert_dom_equal expected, output_buffer
3315
+ end
3316
+
3317
+ def test_lazy_loading_form_builder_override
3318
+ self.default_form_builder = "FormHelperTest::LabelledFormBuilder"
3319
+
3320
+ output_buffer = fields_for(:post, @post) do |f|
3321
+ concat f.text_field(:title)
3322
+ end
3323
+
3324
+ expected = "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
3325
+
3326
+ assert_dom_equal expected, output_buffer
3327
+ end
3328
+
3329
+ def test_fields_for_with_labelled_builder
3330
+ output_buffer = fields_for(:post, @post, builder: LabelledFormBuilder) do |f|
3331
+ concat f.text_field(:title)
3332
+ concat f.text_area(:body)
3333
+ concat f.check_box(:secret)
3334
+ end
3335
+
3336
+ expected =
3337
+ "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" \
3338
+ "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" \
3339
+ "<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/>"
3340
+
3341
+ assert_dom_equal expected, output_buffer
3342
+ end
3343
+
3344
+ def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash
3345
+ klass = nil
3346
+
3347
+ form_for(@post, builder: LabelledFormBuilder) do |f|
3348
+ f.fields_for(:comments, Comment.new) do |nested_fields|
3349
+ klass = nested_fields.class
3350
+ ""
3351
+ end
3352
+ end
3353
+
3354
+ assert_equal LabelledFormBuilder, klass
3355
+ end
3356
+
3357
+ def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash
3358
+ klass = nil
3359
+
3360
+ form_for(@post, builder: LabelledFormBuilder) do |f|
3361
+ f.fields_for(:comments, Comment.new, index: "foo") do |nested_fields|
3362
+ klass = nested_fields.class
3363
+ ""
3364
+ end
3365
+ end
3366
+
3367
+ assert_equal LabelledFormBuilder, klass
3368
+ end
3369
+
3370
+ def test_form_for_with_labelled_builder_path
3371
+ path = nil
3372
+
3373
+ form_for(@post, builder: LabelledFormBuilder) do |f|
3374
+ path = f.to_partial_path
3375
+ ""
3376
+ end
3377
+
3378
+ assert_equal "labelled_form", path
3379
+ end
3380
+
3381
+ class LabelledFormBuilderSubclass < LabelledFormBuilder; end
3382
+
3383
+ def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder
3384
+ klass = nil
3385
+
3386
+ form_for(@post, builder: LabelledFormBuilder) do |f|
3387
+ f.fields_for(:comments, Comment.new, builder: LabelledFormBuilderSubclass) do |nested_fields|
3388
+ klass = nested_fields.class
3389
+ ""
3390
+ end
3391
+ end
3392
+
3393
+ assert_equal LabelledFormBuilderSubclass, klass
3394
+ end
3395
+
3396
+ def test_form_for_with_html_options_adds_options_to_form_tag
3397
+ form_for(@post, html: { id: "some_form", class: "some_class", multipart: true }) do |f| end
3398
+ expected = whole_form("/posts/123", "some_form", "some_class", method: "patch", multipart: "multipart/form-data")
3399
+
3400
+ assert_dom_equal expected, output_buffer
3401
+ end
3402
+
3403
+ def test_form_for_with_string_url_option
3404
+ form_for(@post, url: "http://www.otherdomain.com") do |f| end
3405
+
3406
+ assert_dom_equal whole_form("http://www.otherdomain.com", "edit_post_123", "edit_post", method: "patch"), output_buffer
3407
+ end
3408
+
3409
+ def test_form_for_with_hash_url_option
3410
+ form_for(@post, url: { controller: "controller", action: "action" }) do |f| end
3411
+
3412
+ assert_equal "controller", @url_for_options[:controller]
3413
+ assert_equal "action", @url_for_options[:action]
3414
+ end
3415
+
3416
+ def test_form_for_with_record_url_option
3417
+ form_for(@post, url: @post) do |f| end
3418
+
3419
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
3420
+ assert_dom_equal expected, output_buffer
3421
+ end
3422
+
3423
+ def test_form_for_with_existing_object
3424
+ form_for(@post) do |f| end
3425
+
3426
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
3427
+ assert_dom_equal expected, output_buffer
3428
+ end
3429
+
3430
+ def test_form_for_with_new_object
3431
+ post = Post.new
3432
+ post.persisted = false
3433
+ def post.to_key; nil; end
3434
+
3435
+ form_for(post) do |f| end
3436
+
3437
+ expected = whole_form("/posts", "new_post", "new_post")
3438
+ assert_dom_equal expected, output_buffer
3439
+ end
3440
+
3441
+ def test_form_for_with_existing_object_in_list
3442
+ @comment.save
3443
+ form_for([@post, @comment]) {}
3444
+
3445
+ expected = whole_form(post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch")
3446
+ assert_dom_equal expected, output_buffer
3447
+ end
3448
+
3449
+ def test_form_for_with_new_object_in_list
3450
+ form_for([@post, @comment]) {}
3451
+
3452
+ expected = whole_form(post_comments_path(@post), "new_comment", "new_comment")
3453
+ assert_dom_equal expected, output_buffer
3454
+ end
3455
+
3456
+ def test_form_for_with_existing_object_and_namespace_in_list
3457
+ @comment.save
3458
+ form_for([:admin, @post, @comment]) {}
3459
+
3460
+ expected = whole_form(admin_post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch")
3461
+ assert_dom_equal expected, output_buffer
3462
+ end
3463
+
3464
+ def test_form_for_with_new_object_and_namespace_in_list
3465
+ form_for([:admin, @post, @comment]) {}
3466
+
3467
+ expected = whole_form(admin_post_comments_path(@post), "new_comment", "new_comment")
3468
+ assert_dom_equal expected, output_buffer
3469
+ end
3470
+
3471
+ def test_form_for_with_existing_object_and_custom_url
3472
+ form_for(@post, url: "/super_posts") do |f| end
3473
+
3474
+ expected = whole_form("/super_posts", "edit_post_123", "edit_post", method: "patch")
3475
+ assert_dom_equal expected, output_buffer
3476
+ end
3477
+
3478
+ def test_form_for_with_default_method_as_patch
3479
+ form_for(@post) {}
3480
+ expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
3481
+ assert_dom_equal expected, output_buffer
3482
+ end
3483
+
3484
+ def test_form_for_with_data_attributes
3485
+ form_for(@post, data: { behavior: "stuff" }, remote: true) {}
3486
+ assert_match %r|data-behavior="stuff"|, output_buffer
3487
+ assert_match %r|data-remote="true"|, output_buffer
3488
+ end
3489
+
3490
+ def test_fields_for_returns_block_result
3491
+ output = fields_for(Post.new) { |f| "fields" }
3492
+ assert_equal "fields", output
3493
+ end
3494
+
3495
+ def test_form_for_only_instantiates_builder_once
3496
+ initialization_count = 0
3497
+ builder_class = Class.new(ActionView::Helpers::FormBuilder) do
3498
+ define_method :initialize do |*args|
3499
+ super(*args)
3500
+ initialization_count += 1
3501
+ end
3502
+ end
3503
+
3504
+ form_for(@post, builder: builder_class) {}
3505
+ assert_equal 1, initialization_count, "form builder instantiated more than once"
3506
+ end
3507
+
3508
+ private
3509
+
3510
+ def hidden_fields(options = {})
3511
+ method = options[:method]
3512
+
3513
+ if options.fetch(:enforce_utf8, true)
3514
+ txt = %{<input name="utf8" type="hidden" value="&#x2713;" />}.dup
3515
+ else
3516
+ txt = "".dup
3517
+ end
3518
+
3519
+ if method && !%w(get post).include?(method.to_s)
3520
+ txt << %{<input name="_method" type="hidden" value="#{method}" />}
3521
+ end
3522
+
3523
+ txt
3524
+ end
3525
+
3526
+ def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil)
3527
+ txt = %{<form accept-charset="UTF-8" action="#{action}"}.dup
3528
+ txt << %{ enctype="multipart/form-data"} if multipart
3529
+ txt << %{ data-remote="true"} if remote
3530
+ txt << %{ class="#{html_class}"} if html_class
3531
+ txt << %{ id="#{id}"} if id
3532
+ method = method.to_s == "get" ? "get" : "post"
3533
+ txt << %{ method="#{method}">}
3534
+ end
3535
+
3536
+ def whole_form(action = "/", id = nil, html_class = nil, options = {})
3537
+ contents = block_given? ? yield : ""
3538
+
3539
+ method, remote, multipart = options.values_at(:method, :remote, :multipart)
3540
+
3541
+ form_text(action, id, html_class, remote, multipart, method) + hidden_fields(options.slice :method, :enforce_utf8) + contents + "</form>"
3542
+ end
3543
+
3544
+ def protect_against_forgery?
3545
+ false
3546
+ end
3547
+
3548
+ def with_locale(testing_locale = :label)
3549
+ old_locale, I18n.locale = I18n.locale, testing_locale
3550
+ yield
3551
+ ensure
3552
+ I18n.locale = old_locale
3553
+ end
3554
+ end