actionpack 1.13.6 → 2.0.0

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

Potentially problematic release.


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

Files changed (317) hide show
  1. data/CHANGELOG +1400 -20
  2. data/MIT-LICENSE +1 -1
  3. data/README +5 -5
  4. data/RUNNING_UNIT_TESTS +4 -5
  5. data/Rakefile +5 -6
  6. data/install.rb +2 -2
  7. data/lib/action_controller.rb +11 -15
  8. data/lib/action_controller/assertions.rb +12 -25
  9. data/lib/action_controller/assertions/dom_assertions.rb +18 -4
  10. data/lib/action_controller/assertions/model_assertions.rb +8 -1
  11. data/lib/action_controller/assertions/response_assertions.rb +35 -12
  12. data/lib/action_controller/assertions/routing_assertions.rb +56 -12
  13. data/lib/action_controller/assertions/selector_assertions.rb +105 -38
  14. data/lib/action_controller/assertions/tag_assertions.rb +28 -15
  15. data/lib/action_controller/base.rb +318 -250
  16. data/lib/action_controller/benchmarking.rb +33 -29
  17. data/lib/action_controller/caching.rb +130 -64
  18. data/lib/action_controller/cgi_ext.rb +16 -0
  19. data/lib/action_controller/cgi_ext/{cookie_performance_fix.rb → cookie.rb} +25 -40
  20. data/lib/action_controller/cgi_ext/query_extension.rb +22 -0
  21. data/lib/action_controller/cgi_ext/session.rb +73 -0
  22. data/lib/action_controller/cgi_ext/stdinput.rb +23 -0
  23. data/lib/action_controller/cgi_process.rb +34 -57
  24. data/lib/action_controller/components.rb +19 -36
  25. data/lib/action_controller/cookies.rb +10 -9
  26. data/lib/action_controller/dispatcher.rb +195 -0
  27. data/lib/action_controller/filters.rb +35 -34
  28. data/lib/action_controller/flash.rb +30 -35
  29. data/lib/action_controller/helpers.rb +121 -47
  30. data/lib/action_controller/http_authentication.rb +126 -0
  31. data/lib/action_controller/integration.rb +105 -101
  32. data/lib/action_controller/layout.rb +59 -47
  33. data/lib/action_controller/mime_responds.rb +57 -68
  34. data/lib/action_controller/mime_type.rb +43 -80
  35. data/lib/action_controller/mime_types.rb +20 -0
  36. data/lib/action_controller/polymorphic_routes.rb +88 -0
  37. data/lib/action_controller/record_identifier.rb +91 -0
  38. data/lib/action_controller/request.rb +553 -88
  39. data/lib/action_controller/request_forgery_protection.rb +126 -0
  40. data/lib/action_controller/request_profiler.rb +138 -0
  41. data/lib/action_controller/rescue.rb +185 -69
  42. data/lib/action_controller/resources.rb +211 -172
  43. data/lib/action_controller/response.rb +49 -8
  44. data/lib/action_controller/routing.rb +359 -236
  45. data/lib/action_controller/routing_optimisation.rb +119 -0
  46. data/lib/action_controller/session/active_record_store.rb +3 -2
  47. data/lib/action_controller/session/cookie_store.rb +161 -0
  48. data/lib/action_controller/session/mem_cache_store.rb +9 -16
  49. data/lib/action_controller/session_management.rb +17 -8
  50. data/lib/action_controller/streaming.rb +6 -3
  51. data/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
  52. data/lib/action_controller/templates/rescues/{_trace.rhtml → _trace.erb} +0 -0
  53. data/lib/action_controller/templates/rescues/{diagnostics.rhtml → diagnostics.erb} +2 -2
  54. data/lib/action_controller/templates/rescues/{layout.rhtml → layout.erb} +0 -0
  55. data/lib/action_controller/templates/rescues/{missing_template.rhtml → missing_template.erb} +0 -0
  56. data/lib/action_controller/templates/rescues/{routing_error.rhtml → routing_error.erb} +0 -0
  57. data/lib/action_controller/templates/rescues/{template_error.rhtml → template_error.erb} +2 -2
  58. data/lib/action_controller/templates/rescues/{unknown_action.rhtml → unknown_action.erb} +0 -0
  59. data/lib/action_controller/test_case.rb +53 -0
  60. data/lib/action_controller/test_process.rb +59 -46
  61. data/lib/action_controller/url_rewriter.rb +48 -24
  62. data/lib/action_controller/vendor/html-scanner/html/document.rb +7 -4
  63. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
  64. data/lib/action_controller/vendor/html-scanner/html/selector.rb +11 -6
  65. data/lib/action_controller/verification.rb +27 -21
  66. data/lib/action_pack.rb +1 -1
  67. data/lib/action_pack/version.rb +4 -4
  68. data/lib/action_view.rb +2 -3
  69. data/lib/action_view/base.rb +218 -63
  70. data/lib/action_view/compiled_templates.rb +1 -2
  71. data/lib/action_view/helpers/active_record_helper.rb +35 -17
  72. data/lib/action_view/helpers/asset_tag_helper.rb +395 -87
  73. data/lib/action_view/helpers/atom_feed_helper.rb +111 -0
  74. data/lib/action_view/helpers/benchmark_helper.rb +12 -5
  75. data/lib/action_view/helpers/cache_helper.rb +29 -0
  76. data/lib/action_view/helpers/capture_helper.rb +97 -63
  77. data/lib/action_view/helpers/date_helper.rb +295 -35
  78. data/lib/action_view/helpers/debug_helper.rb +6 -2
  79. data/lib/action_view/helpers/form_helper.rb +354 -111
  80. data/lib/action_view/helpers/form_options_helper.rb +171 -109
  81. data/lib/action_view/helpers/form_tag_helper.rb +332 -76
  82. data/lib/action_view/helpers/javascript_helper.rb +35 -11
  83. data/lib/action_view/helpers/javascripts/controls.js +484 -354
  84. data/lib/action_view/helpers/javascripts/dragdrop.js +88 -58
  85. data/lib/action_view/helpers/javascripts/effects.js +396 -364
  86. data/lib/action_view/helpers/javascripts/prototype.js +2817 -1107
  87. data/lib/action_view/helpers/number_helper.rb +84 -60
  88. data/lib/action_view/helpers/prototype_helper.rb +419 -43
  89. data/lib/action_view/helpers/record_identification_helper.rb +20 -0
  90. data/lib/action_view/helpers/record_tag_helper.rb +59 -0
  91. data/lib/action_view/helpers/sanitize_helper.rb +223 -0
  92. data/lib/action_view/helpers/scriptaculous_helper.rb +63 -4
  93. data/lib/action_view/helpers/tag_helper.rb +69 -39
  94. data/lib/action_view/helpers/text_helper.rb +221 -148
  95. data/lib/action_view/helpers/url_helper.rb +283 -165
  96. data/lib/action_view/partials.rb +134 -62
  97. data/lib/action_view/template_error.rb +4 -12
  98. data/lib/actionpack.rb +1 -0
  99. data/test/abstract_unit.rb +21 -1
  100. data/test/action_view_test.rb +26 -0
  101. data/test/active_record_unit.rb +12 -20
  102. data/test/activerecord/active_record_store_test.rb +2 -2
  103. data/test/activerecord/render_partial_with_record_identification_test.rb +74 -0
  104. data/test/controller/action_pack_assertions_test.rb +21 -152
  105. data/test/controller/addresses_render_test.rb +2 -7
  106. data/test/controller/assert_select_test.rb +120 -14
  107. data/test/controller/base_test.rb +11 -13
  108. data/test/controller/caching_test.rb +125 -5
  109. data/test/controller/capture_test.rb +23 -16
  110. data/test/controller/cgi_test.rb +66 -391
  111. data/test/controller/components_test.rb +31 -42
  112. data/test/controller/content_type_test.rb +1 -1
  113. data/test/controller/cookie_test.rb +42 -14
  114. data/test/controller/deprecation/deprecated_base_methods_test.rb +1 -42
  115. data/test/controller/dispatcher_test.rb +123 -0
  116. data/test/controller/fake_models.rb +5 -0
  117. data/test/controller/filters_test.rb +44 -7
  118. data/test/controller/flash_test.rb +46 -2
  119. data/test/controller/fragment_store_setting_test.rb +10 -8
  120. data/test/controller/helper_test.rb +19 -2
  121. data/test/controller/html-scanner/document_test.rb +124 -0
  122. data/test/controller/html-scanner/node_test.rb +69 -0
  123. data/test/controller/html-scanner/sanitizer_test.rb +250 -0
  124. data/test/controller/html-scanner/tag_node_test.rb +239 -0
  125. data/test/controller/html-scanner/text_node_test.rb +51 -0
  126. data/test/controller/html-scanner/tokenizer_test.rb +125 -0
  127. data/test/controller/http_authentication_test.rb +54 -0
  128. data/test/controller/integration_test.rb +12 -26
  129. data/test/controller/layout_test.rb +64 -12
  130. data/test/controller/mime_responds_test.rb +193 -38
  131. data/test/controller/mime_type_test.rb +30 -8
  132. data/test/controller/new_render_test.rb +104 -22
  133. data/test/controller/polymorphic_routes_test.rb +98 -0
  134. data/test/controller/record_identifier_test.rb +103 -0
  135. data/test/controller/redirect_test.rb +120 -18
  136. data/test/controller/render_test.rb +195 -45
  137. data/test/controller/request_forgery_protection_test.rb +217 -0
  138. data/test/controller/request_test.rb +545 -27
  139. data/test/controller/rescue_test.rb +501 -0
  140. data/test/controller/resources_test.rb +258 -132
  141. data/test/controller/routing_test.rb +502 -106
  142. data/test/controller/selector_test.rb +5 -5
  143. data/test/controller/send_file_test.rb +17 -7
  144. data/test/controller/session/cookie_store_test.rb +246 -0
  145. data/test/controller/session/mem_cache_store_test.rb +182 -0
  146. data/test/controller/session_fixation_test.rb +8 -11
  147. data/test/controller/session_management_test.rb +7 -7
  148. data/test/controller/test_test.rb +150 -38
  149. data/test/controller/url_rewriter_test.rb +87 -12
  150. data/test/controller/verification_test.rb +11 -0
  151. data/test/controller/view_paths_test.rb +137 -0
  152. data/test/controller/webservice_test.rb +11 -75
  153. data/test/fixtures/addresses/{list.rhtml → list.erb} +0 -0
  154. data/test/fixtures/db_definitions/sqlite.sql +2 -1
  155. data/test/fixtures/developer.rb +2 -0
  156. data/test/fixtures/fun/games/{hello_world.rhtml → hello_world.erb} +0 -0
  157. data/test/fixtures/helpers/fun/pdf_helper.rb +1 -1
  158. data/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
  159. data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
  160. data/test/fixtures/layouts/{builder.rxml → builder.builder} +0 -0
  161. data/test/fixtures/layouts/{standard.rhtml → standard.erb} +0 -0
  162. data/test/fixtures/layouts/{talk_from_action.rhtml → talk_from_action.erb} +0 -0
  163. data/test/fixtures/layouts/{yield.rhtml → yield.erb} +0 -0
  164. data/test/fixtures/multipart/binary_file +0 -0
  165. data/test/fixtures/multipart/bracketed_param +5 -0
  166. data/test/fixtures/override/test/hello_world.erb +1 -0
  167. data/test/fixtures/override2/layouts/test/sub.erb +1 -0
  168. data/test/fixtures/post_test/layouts/post.html.erb +1 -0
  169. data/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
  170. data/test/fixtures/post_test/post/index.html.erb +1 -0
  171. data/test/fixtures/post_test/post/index.iphone.erb +1 -0
  172. data/test/fixtures/post_test/super_post/index.html.erb +1 -0
  173. data/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
  174. data/test/fixtures/public/404.html +1 -0
  175. data/test/fixtures/public/500.html +1 -0
  176. data/test/fixtures/public/javascripts/application.js +0 -1
  177. data/test/fixtures/public/javascripts/bank.js +1 -0
  178. data/test/fixtures/public/javascripts/robber.js +1 -0
  179. data/test/fixtures/public/stylesheets/bank.css +1 -0
  180. data/test/fixtures/public/stylesheets/robber.css +1 -0
  181. data/test/fixtures/replies.yml +2 -0
  182. data/test/fixtures/reply.rb +2 -1
  183. data/test/fixtures/respond_to/{all_types_with_layout.rhtml → all_types_with_layout.html.erb} +0 -0
  184. data/test/fixtures/respond_to/{all_types_with_layout.rjs → all_types_with_layout.js.rjs} +0 -0
  185. data/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
  186. data/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
  187. data/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
  188. data/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
  189. data/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
  190. data/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
  191. data/test/fixtures/respond_to/{using_defaults.rhtml → using_defaults.html.erb} +0 -0
  192. data/test/fixtures/respond_to/{using_defaults.rjs → using_defaults.js.rjs} +0 -0
  193. data/test/fixtures/respond_to/{using_defaults.rxml → using_defaults.xml.builder} +0 -0
  194. data/test/fixtures/respond_to/{using_defaults_with_type_list.rhtml → using_defaults_with_type_list.html.erb} +0 -0
  195. data/test/fixtures/respond_to/{using_defaults_with_type_list.rjs → using_defaults_with_type_list.js.rjs} +0 -0
  196. data/test/fixtures/respond_to/{using_defaults_with_type_list.rxml → using_defaults_with_type_list.xml.builder} +0 -0
  197. data/test/fixtures/scope/test/{modgreet.rhtml → modgreet.erb} +0 -0
  198. data/test/fixtures/test/{_customer.rhtml → _customer.erb} +0 -0
  199. data/test/fixtures/test/{_customer_greeting.rhtml → _customer_greeting.erb} +0 -0
  200. data/test/fixtures/test/_hash_greeting.erb +1 -0
  201. data/test/fixtures/test/_hash_object.erb +2 -0
  202. data/test/fixtures/test/{_hello.rxml → _hello.builder} +0 -0
  203. data/test/fixtures/test/_layout_for_partial.html.erb +3 -0
  204. data/test/fixtures/test/_partial.erb +1 -0
  205. data/test/fixtures/test/_partial.html.erb +1 -0
  206. data/test/fixtures/test/_partial.js.erb +1 -0
  207. data/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
  208. data/test/fixtures/test/{_partial_only.rhtml → _partial_only.erb} +0 -0
  209. data/test/fixtures/test/{_person.rhtml → _person.erb} +0 -0
  210. data/test/fixtures/test/{action_talk_to_layout.rhtml → action_talk_to_layout.erb} +0 -0
  211. data/test/fixtures/test/{block_content_for.rhtml → block_content_for.erb} +0 -0
  212. data/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
  213. data/test/fixtures/test/{capturing.rhtml → capturing.erb} +0 -0
  214. data/test/fixtures/test/{content_for.rhtml → content_for.erb} +0 -0
  215. data/test/fixtures/test/content_for_concatenated.erb +3 -0
  216. data/test/fixtures/test/content_for_with_parameter.erb +2 -0
  217. data/test/fixtures/test/dot.directory/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
  218. data/test/fixtures/test/{erb_content_for.rhtml → erb_content_for.erb} +0 -0
  219. data/test/fixtures/test/formatted_html_erb.html.erb +1 -0
  220. data/test/fixtures/test/formatted_xml_erb.builder +1 -0
  221. data/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
  222. data/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
  223. data/test/fixtures/test/{greeting.rhtml → greeting.erb} +0 -0
  224. data/test/fixtures/test/{hello.rxml → hello.builder} +0 -0
  225. data/test/fixtures/test/{hello_world.rxml → hello_world.builder} +0 -0
  226. data/test/fixtures/test/{hello_world.rhtml → hello_world.erb} +0 -0
  227. data/test/fixtures/test/{hello_world_container.rxml → hello_world_container.builder} +0 -0
  228. data/test/fixtures/test/{hello_world_with_layout_false.rhtml → hello_world_with_layout_false.erb} +0 -0
  229. data/test/fixtures/test/{hello_xml_world.rxml → hello_xml_world.builder} +0 -0
  230. data/test/fixtures/test/list.erb +1 -0
  231. data/test/fixtures/test/{non_erb_block_content_for.rxml → non_erb_block_content_for.builder} +0 -0
  232. data/test/fixtures/test/{potential_conflicts.rhtml → potential_conflicts.erb} +0 -0
  233. data/test/fixtures/test/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
  234. data/test/fixtures/test/{render_file_with_locals.rhtml → render_file_with_locals.erb} +0 -0
  235. data/test/fixtures/test/{render_to_string_test.rhtml → render_to_string_test.erb} +0 -0
  236. data/test/fixtures/test/{update_element_with_capture.rhtml → update_element_with_capture.erb} +0 -0
  237. data/test/fixtures/test/using_layout_around_block.html.erb +1 -0
  238. data/test/fixtures/topic.rb +1 -1
  239. data/test/template/active_record_helper_test.rb +67 -20
  240. data/test/template/asset_tag_helper_test.rb +222 -54
  241. data/test/template/atom_feed_helper_test.rb +101 -0
  242. data/test/template/benchmark_helper_test.rb +2 -2
  243. data/test/template/compiled_templates_test.rb +76 -32
  244. data/test/template/date_helper_test.rb +125 -9
  245. data/test/template/form_helper_test.rb +326 -33
  246. data/test/template/form_options_helper_test.rb +822 -15
  247. data/test/template/form_tag_helper_test.rb +96 -30
  248. data/test/template/javascript_helper_test.rb +61 -13
  249. data/test/template/number_helper_test.rb +12 -11
  250. data/test/template/prototype_helper_test.rb +185 -24
  251. data/test/template/sanitize_helper_test.rb +49 -0
  252. data/test/template/scriptaculous_helper_test.rb +9 -3
  253. data/test/template/tag_helper_test.rb +13 -2
  254. data/test/template/text_helper_test.rb +38 -52
  255. data/test/template/url_helper_test.rb +216 -46
  256. metadata +144 -116
  257. data/examples/.htaccess +0 -24
  258. data/examples/address_book/index.rhtml +0 -33
  259. data/examples/address_book/layout.rhtml +0 -8
  260. data/examples/address_book_controller.cgi +0 -9
  261. data/examples/address_book_controller.fcgi +0 -6
  262. data/examples/address_book_controller.rb +0 -52
  263. data/examples/address_book_controller.rbx +0 -4
  264. data/examples/benchmark.rb +0 -52
  265. data/examples/benchmark_with_ar.fcgi +0 -89
  266. data/examples/blog_controller.cgi +0 -53
  267. data/examples/debate/index.rhtml +0 -14
  268. data/examples/debate/new_topic.rhtml +0 -22
  269. data/examples/debate/topic.rhtml +0 -32
  270. data/examples/debate_controller.cgi +0 -57
  271. data/lib/action_controller/assertions/deprecated_assertions.rb +0 -228
  272. data/lib/action_controller/cgi_ext/cgi_ext.rb +0 -36
  273. data/lib/action_controller/cgi_ext/cgi_methods.rb +0 -211
  274. data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +0 -30
  275. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +0 -95
  276. data/lib/action_controller/cgi_ext/session_performance_fix.rb +0 -30
  277. data/lib/action_controller/deprecated_dependencies.rb +0 -65
  278. data/lib/action_controller/deprecated_redirects.rb +0 -17
  279. data/lib/action_controller/deprecated_request_methods.rb +0 -34
  280. data/lib/action_controller/macros/auto_complete.rb +0 -53
  281. data/lib/action_controller/macros/in_place_editing.rb +0 -33
  282. data/lib/action_controller/pagination.rb +0 -408
  283. data/lib/action_controller/scaffolding.rb +0 -189
  284. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -44
  285. data/lib/action_controller/templates/scaffolds/edit.rhtml +0 -7
  286. data/lib/action_controller/templates/scaffolds/layout.rhtml +0 -69
  287. data/lib/action_controller/templates/scaffolds/list.rhtml +0 -27
  288. data/lib/action_controller/templates/scaffolds/new.rhtml +0 -6
  289. data/lib/action_controller/templates/scaffolds/show.rhtml +0 -9
  290. data/lib/action_controller/vendor/xml_node.rb +0 -97
  291. data/lib/action_view/helpers/deprecated_helper.rb +0 -37
  292. data/lib/action_view/helpers/java_script_macros_helper.rb +0 -233
  293. data/lib/action_view/helpers/pagination_helper.rb +0 -86
  294. data/test/activerecord/active_record_assertions_test.rb +0 -92
  295. data/test/activerecord/pagination_test.rb +0 -165
  296. data/test/controller/deprecated_instance_variables_test.rb +0 -48
  297. data/test/controller/raw_post_test.rb +0 -68
  298. data/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml +0 -1
  299. data/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml +0 -1
  300. data/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml +0 -1
  301. data/test/fixtures/deprecated_instance_variables/_flash_method.rhtml +0 -1
  302. data/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml +0 -1
  303. data/test/fixtures/deprecated_instance_variables/_headers_method.rhtml +0 -1
  304. data/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml +0 -1
  305. data/test/fixtures/deprecated_instance_variables/_params_method.rhtml +0 -1
  306. data/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml +0 -1
  307. data/test/fixtures/deprecated_instance_variables/_request_method.rhtml +0 -1
  308. data/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml +0 -1
  309. data/test/fixtures/deprecated_instance_variables/_response_method.rhtml +0 -1
  310. data/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml +0 -1
  311. data/test/fixtures/deprecated_instance_variables/_session_method.rhtml +0 -1
  312. data/test/fixtures/respond_to/layouts/standard.rhtml +0 -1
  313. data/test/fixtures/test/_hash_object.rhtml +0 -1
  314. data/test/fixtures/test/list.rhtml +0 -1
  315. data/test/template/deprecated_helper_test.rb +0 -36
  316. data/test/template/deprecated_instance_variables_test.rb +0 -43
  317. data/test/template/java_script_macros_helper_test.rb +0 -109
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2006 David Heinemeier Hansson
1
+ Copyright (c) 2004-2007 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -382,7 +382,7 @@ methods:
382
382
  end
383
383
  end
384
384
 
385
- WeblogController::Base.template_root = File.dirname(__FILE__)
385
+ WeblogController::Base.view_paths = [ File.dirname(__FILE__) ]
386
386
  WeblogController.process_cgi if $0 == __FILE__
387
387
 
388
388
  The last two lines are responsible for telling ActionController where the
@@ -391,23 +391,23 @@ request from the web-server (like to be Apache).
391
391
 
392
392
  And the templates look like this:
393
393
 
394
- weblog/layout.rhtml:
394
+ weblog/layout.erb:
395
395
  <html><body>
396
396
  <%= yield %>
397
397
  </body></html>
398
398
 
399
- weblog/index.rhtml:
399
+ weblog/index.erb:
400
400
  <% for post in @posts %>
401
401
  <p><%= link_to(post.title, :action => "display", :id => post.id %></p>
402
402
  <% end %>
403
403
 
404
- weblog/display.rhtml:
404
+ weblog/display.erb:
405
405
  <p>
406
406
  <b><%= post.title %></b><br/>
407
407
  <b><%= post.content %></b>
408
408
  </p>
409
409
 
410
- weblog/new.rhtml:
410
+ weblog/new.erb:
411
411
  <%= form "post" %>
412
412
 
413
413
  This simple setup will list all the posts in the system on the index page,
@@ -15,11 +15,10 @@ you can do so with something like:
15
15
 
16
16
  == Dependency on ActiveRecord and database setup
17
17
 
18
- Test cases in test/controller/active_record_assertions.rb depend on having
19
- activerecord installed and configured in a particular way. See comment in the
20
- test file itself for details. If ActiveRecord is not in
21
- actionpack/../activerecord directory, these tests are skipped. If activerecord
22
- is installed, but not configured as expected, the tests will fail.
18
+ Test cases in the test/controller/active_record/ directory depend on having
19
+ activerecord and sqlite installed. If ActiveRecord is not in
20
+ actionpack/../activerecord directory, or the sqlite rubygem is not installed,
21
+ these tests are skipped.
23
22
 
24
23
  Other tests are runnable from a fresh copy of actionpack without any configuration.
25
24
 
data/Rakefile CHANGED
@@ -48,6 +48,7 @@ Rake::RDocTask.new { |rdoc|
48
48
  rdoc.rdoc_dir = 'doc'
49
49
  rdoc.title = "Action Pack -- On rails from request to response"
50
50
  rdoc.options << '--line-numbers' << '--inline-source'
51
+ rdoc.options << '--charset' << 'utf-8'
51
52
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
52
53
  if ENV['DOC_FILES']
53
54
  rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
@@ -58,7 +59,7 @@ Rake::RDocTask.new { |rdoc|
58
59
  }
59
60
 
60
61
  # Create compressed packages
61
- dist_dirs = [ "lib", "test", "examples" ]
62
+ dist_dirs = [ "lib", "test" ]
62
63
 
63
64
  spec = Gem::Specification.new do |s|
64
65
  s.platform = Gem::Platform::RUBY
@@ -75,17 +76,15 @@ spec = Gem::Specification.new do |s|
75
76
  s.has_rdoc = true
76
77
  s.requirements << 'none'
77
78
 
78
- s.add_dependency('activesupport', '= 1.4.4' + PKG_BUILD)
79
+ s.add_dependency('activesupport', '= 2.0.0' + PKG_BUILD)
79
80
 
80
81
  s.require_path = 'lib'
81
82
  s.autorequire = 'action_controller'
82
83
 
83
- s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE", "examples/.htaccess" ]
84
+ s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ]
84
85
  dist_dirs.each do |dir|
85
86
  s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
86
87
  end
87
- s.files.delete "examples/benchmark.rb"
88
- s.files.delete "examples/benchmark_with_ar.fcgi"
89
88
  end
90
89
 
91
90
  Rake::GemPackageTask.new(spec) do |p|
@@ -151,4 +150,4 @@ task :release => [ :package ] do
151
150
  rubyforge = RubyForge.new
152
151
  rubyforge.login
153
152
  rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
154
- end
153
+ end
data/install.rb CHANGED
@@ -4,7 +4,7 @@ require 'ftools'
4
4
 
5
5
  include Config
6
6
 
7
- # this was adapted from rdoc's install.rb by ways of Log4r
7
+ # this was adapted from rdoc's install.rb by way of Log4r
8
8
 
9
9
  $sitedir = CONFIG["sitelibdir"]
10
10
  unless $sitedir
@@ -18,7 +18,7 @@ unless $sitedir
18
18
  end
19
19
  end
20
20
 
21
- # the acual gruntwork
21
+ # the actual gruntwork
22
22
  Dir.chdir("lib")
23
23
 
24
24
  Find.find("action_controller", "action_controller.rb", "action_view", "action_view.rb") { |f|
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2006 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2007 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -26,27 +26,24 @@ $:.unshift(File.dirname(__FILE__)) unless
26
26
 
27
27
  unless defined?(ActiveSupport)
28
28
  begin
29
- $:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib")
30
- require 'active_support'
29
+ $:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
30
+ require 'active_support'
31
31
  rescue LoadError
32
32
  require 'rubygems'
33
33
  gem 'activesupport'
34
34
  end
35
35
  end
36
36
 
37
+ $:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner"
38
+
37
39
  require 'action_controller/base'
38
- require 'action_controller/deprecated_redirects'
39
40
  require 'action_controller/request'
40
- require 'action_controller/deprecated_request_methods'
41
41
  require 'action_controller/rescue'
42
42
  require 'action_controller/benchmarking'
43
43
  require 'action_controller/flash'
44
44
  require 'action_controller/filters'
45
45
  require 'action_controller/layout'
46
- require 'action_controller/deprecated_dependencies'
47
46
  require 'action_controller/mime_responds'
48
- require 'action_controller/pagination'
49
- require 'action_controller/scaffolding'
50
47
  require 'action_controller/helpers'
51
48
  require 'action_controller/cookies'
52
49
  require 'action_controller/cgi_process'
@@ -54,9 +51,10 @@ require 'action_controller/caching'
54
51
  require 'action_controller/verification'
55
52
  require 'action_controller/streaming'
56
53
  require 'action_controller/session_management'
54
+ require 'action_controller/http_authentication'
57
55
  require 'action_controller/components'
58
- require 'action_controller/macros/auto_complete'
59
- require 'action_controller/macros/in_place_editing'
56
+ require 'action_controller/record_identifier'
57
+ require 'action_controller/request_forgery_protection'
60
58
 
61
59
  require 'action_view'
62
60
  ActionController::Base.template_class = ActionView::Base
@@ -67,17 +65,15 @@ ActionController::Base.class_eval do
67
65
  include ActionController::Layout
68
66
  include ActionController::Benchmarking
69
67
  include ActionController::Rescue
70
- include ActionController::Dependencies
71
68
  include ActionController::MimeResponds
72
- include ActionController::Pagination
73
- include ActionController::Scaffolding
74
69
  include ActionController::Helpers
75
70
  include ActionController::Cookies
76
71
  include ActionController::Caching
77
72
  include ActionController::Verification
78
73
  include ActionController::Streaming
79
74
  include ActionController::SessionManagement
75
+ include ActionController::HttpAuthentication::Basic::ControllerMethods
80
76
  include ActionController::Components
81
- include ActionController::Macros::AutoComplete
82
- include ActionController::Macros::InPlaceEditing
77
+ include ActionController::RecordIdentifier
78
+ include ActionController::RequestForgeryProtection
83
79
  end
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require 'test/unit/assertions'
3
2
 
4
3
  module ActionController #:nodoc:
@@ -9,7 +8,7 @@ module ActionController #:nodoc:
9
8
  # * session: Objects being saved in the session.
10
9
  # * flash: The flash objects currently in the session.
11
10
  # * cookies: Cookies being sent to the user on this request.
12
- #
11
+ #
13
12
  # These collections can be used just like any other hash:
14
13
  #
15
14
  # assert_not_nil assigns(:person) # makes sure that a @person instance variable was set
@@ -17,7 +16,7 @@ module ActionController #:nodoc:
17
16
  # assert flash.empty? # makes sure that there's nothing in the flash
18
17
  #
19
18
  # For historic reasons, the assigns hash uses string-based keys. So assigns[:person] won't work, but assigns["person"] will. To
20
- # appease our yearning for symbols, though, an alternative accessor has been deviced using a method call instead of index referencing.
19
+ # appease our yearning for symbols, though, an alternative accessor has been devised using a method call instead of index referencing.
21
20
  # So assigns(:person) will work just like assigns["person"], but again, assigns[:person] will not work.
22
21
  #
23
22
  # On top of the collections, you have the complete url that a given action redirected to available in redirect_to_url.
@@ -39,44 +38,32 @@ module ActionController #:nodoc:
39
38
  #
40
39
  # == Testing named routes
41
40
  #
42
- # If you're using named routes, they can be easily tested using the original named routes methods straight in the test case.
43
- # Example:
41
+ # If you're using named routes, they can be easily tested using the original named routes' methods straight in the test case.
42
+ # Example:
44
43
  #
45
44
  # assert_redirected_to page_url(:title => 'foo')
46
45
  module Assertions
47
46
  def self.included(klass)
48
- klass.class_eval do
49
- include ActionController::Assertions::ResponseAssertions
50
- include ActionController::Assertions::SelectorAssertions
51
- include ActionController::Assertions::RoutingAssertions
52
- include ActionController::Assertions::TagAssertions
53
- include ActionController::Assertions::DomAssertions
54
- include ActionController::Assertions::ModelAssertions
55
- include ActionController::Assertions::DeprecatedAssertions
47
+ %w(response selector tag dom routing model).each do |kind|
48
+ require "action_controller/assertions/#{kind}_assertions"
49
+ klass.module_eval { include const_get("#{kind.camelize}Assertions") }
56
50
  end
57
51
  end
58
52
 
59
53
  def clean_backtrace(&block)
60
54
  yield
61
- rescue Test::Unit::AssertionFailedError => e
62
- path = File.expand_path(__FILE__)
63
- raise Test::Unit::AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
55
+ rescue Test::Unit::AssertionFailedError => error
56
+ framework_path = Regexp.new(File.expand_path("#{File.dirname(__FILE__)}/assertions"))
57
+ error.backtrace.reject! { |line| File.expand_path(line) =~ framework_path }
58
+ raise
64
59
  end
65
60
  end
66
61
  end
67
62
 
68
- require File.dirname(__FILE__) + '/assertions/response_assertions'
69
- require File.dirname(__FILE__) + '/assertions/selector_assertions'
70
- require File.dirname(__FILE__) + '/assertions/tag_assertions'
71
- require File.dirname(__FILE__) + '/assertions/dom_assertions'
72
- require File.dirname(__FILE__) + '/assertions/routing_assertions'
73
- require File.dirname(__FILE__) + '/assertions/model_assertions'
74
- require File.dirname(__FILE__) + '/assertions/deprecated_assertions'
75
-
76
63
  module Test #:nodoc:
77
64
  module Unit #:nodoc:
78
65
  class TestCase #:nodoc:
79
66
  include ActionController::Assertions
80
67
  end
81
68
  end
82
- end
69
+ end
@@ -2,24 +2,38 @@ module ActionController
2
2
  module Assertions
3
3
  module DomAssertions
4
4
  # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
5
- def assert_dom_equal(expected, actual, message="")
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # assert that the referenced method generates the appropriate HTML string
9
+ # assert_dom_equal '<a href="http://www.example.com">Apples</a>', link_to("Apples", "http://www.example.com")
10
+ #
11
+ def assert_dom_equal(expected, actual, message = "")
6
12
  clean_backtrace do
7
13
  expected_dom = HTML::Document.new(expected).root
8
- actual_dom = HTML::Document.new(actual).root
14
+ actual_dom = HTML::Document.new(actual).root
9
15
  full_message = build_message(message, "<?> expected to be == to\n<?>.", expected_dom.to_s, actual_dom.to_s)
16
+
10
17
  assert_block(full_message) { expected_dom == actual_dom }
11
18
  end
12
19
  end
13
20
 
14
21
  # The negated form of +assert_dom_equivalent+.
15
- def assert_dom_not_equal(expected, actual, message="")
22
+ #
23
+ # ==== Examples
24
+ #
25
+ # # assert that the referenced method does not generate the specified HTML string
26
+ # assert_dom_not_equal '<a href="http://www.example.com">Apples</a>', link_to("Oranges", "http://www.example.com")
27
+ #
28
+ def assert_dom_not_equal(expected, actual, message = "")
16
29
  clean_backtrace do
17
30
  expected_dom = HTML::Document.new(expected).root
18
31
  actual_dom = HTML::Document.new(actual).root
19
32
  full_message = build_message(message, "<?> expected to be != to\n<?>.", expected_dom.to_s, actual_dom.to_s)
33
+
20
34
  assert_block(full_message) { expected_dom != actual_dom }
21
35
  end
22
36
  end
23
37
  end
24
38
  end
25
- end
39
+ end
@@ -2,6 +2,13 @@ module ActionController
2
2
  module Assertions
3
3
  module ModelAssertions
4
4
  # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # assert that a newly created record is valid
9
+ # model = Model.new
10
+ # assert_valid(model)
11
+ #
5
12
  def assert_valid(record)
6
13
  clean_backtrace do
7
14
  assert record.valid?, record.errors.full_messages.join("\n")
@@ -9,4 +16,4 @@ module ActionController
9
16
  end
10
17
  end
11
18
  end
12
- end
19
+ end
@@ -1,19 +1,29 @@
1
1
  require 'rexml/document'
2
- require File.dirname(__FILE__) + "/../vendor/html-scanner/html/document"
2
+ require 'html/document'
3
3
 
4
4
  module ActionController
5
5
  module Assertions
6
+ # A small suite of assertions that test responses from Rails applications.
6
7
  module ResponseAssertions
7
8
  # Asserts that the response is one of the following types:
8
9
  #
9
- # * <tt>:success</tt>: Status code was 200
10
- # * <tt>:redirect</tt>: Status code was in the 300-399 range
11
- # * <tt>:missing</tt>: Status code was 404
12
- # * <tt>:error</tt>: Status code was in the 500-599 range
10
+ # * <tt>:success</tt> - Status code was 200
11
+ # * <tt>:redirect</tt> - Status code was in the 300-399 range
12
+ # * <tt>:missing</tt> - Status code was 404
13
+ # * <tt>:error</tt> - Status code was in the 500-599 range
13
14
  #
14
15
  # You can also pass an explicit status number like assert_response(501)
15
16
  # or its symbolic equivalent assert_response(:not_implemented).
16
17
  # See ActionController::StatusCodes for a full list.
18
+ #
19
+ # ==== Examples
20
+ #
21
+ # # assert that the response was a redirection
22
+ # assert_response :redirect
23
+ #
24
+ # # assert that the response code was status code 401 (unauthorized)
25
+ # assert_response 401
26
+ #
17
27
  def assert_response(type, message = nil)
18
28
  clean_backtrace do
19
29
  if [ :success, :missing, :redirect, :error ].include?(type) && @response.send("#{type}?")
@@ -28,9 +38,18 @@ module ActionController
28
38
  end
29
39
  end
30
40
 
31
- # Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial,
32
- # such that assert_redirected_to(:controller => "weblog") will also match the redirection of
33
- # redirect_to(:controller => "weblog", :action => "show") and so on.
41
+ # Assert that the redirection options passed in match those of the redirect called in the latest action.
42
+ # This match can be partial, such that assert_redirected_to(:controller => "weblog") will also
43
+ # match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on.
44
+ #
45
+ # ==== Examples
46
+ #
47
+ # # assert that the redirection was to the "index" action on the WeblogController
48
+ # assert_redirected_to :controller => "weblog", :action => "index"
49
+ #
50
+ # # assert that the redirection was to the named route login_url
51
+ # assert_redirected_to login_url
52
+ #
34
53
  def assert_redirected_to(options = {}, message=nil)
35
54
  clean_backtrace do
36
55
  assert_response(:redirect, message)
@@ -79,10 +98,8 @@ module ActionController
79
98
  url[key] = value
80
99
  end
81
100
 
82
-
83
- @response_diff = url[:expected].diff(url[:actual]) if url[:actual]
84
- msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>), difference: <?>",
85
- url[:actual], @response_diff)
101
+ @response_diff = url[:actual].diff(url[:expected]) if url[:actual]
102
+ msg = build_message(message, "expected a redirect to <?>, found one to <?>, a difference of <?> ", url[:expected], url[:actual], @response_diff)
86
103
 
87
104
  assert_block(msg) do
88
105
  url[:expected].keys.all? do |k|
@@ -106,6 +123,12 @@ module ActionController
106
123
  end
107
124
 
108
125
  # Asserts that the request was rendered with the appropriate template file.
126
+ #
127
+ # ==== Examples
128
+ #
129
+ # # assert that the "new" view template was rendered
130
+ # assert_template "new"
131
+ #
109
132
  def assert_template(expected = nil, message=nil)
110
133
  clean_backtrace do
111
134
  rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file
@@ -1,25 +1,41 @@
1
1
  module ActionController
2
2
  module Assertions
3
+ # Suite of assertions to test routes generated by Rails and the handling of requests made to them.
3
4
  module RoutingAssertions
4
- # Asserts that the routing of the given path was handled correctly and that the parsed options match.
5
+ # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
6
+ # match +path+. Basically, it asserts that Rails recognizes the route given by +expected_options+.
5
7
  #
6
- # assert_recognizes({:controller => 'items', :action => 'index'}, 'items') # check the default action
7
- # assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list') # check a specific action
8
- # assert_recognizes({:controller => 'items', :action => 'list', :id => '1'}, 'items/list/1') # check an action with a parameter
9
- #
10
- # Pass a hash in the second argument to specify the request method. This is useful for routes
8
+ # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
11
9
  # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
12
10
  # and a :method containing the required HTTP verb.
13
11
  #
14
12
  # # assert that POSTing to /items will call the create action on ItemsController
15
13
  # assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post})
16
14
  #
17
- # You can also pass in "extras" with a hash containing URL parameters that would normally be in the query string. This can be used
15
+ # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
18
16
  # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
19
17
  # extras argument, appending the query string on the path directly will not work. For example:
20
18
  #
21
19
  # # assert that a path of '/items/list/1?view=print' returns the correct options
22
20
  # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
21
+ #
22
+ # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
23
+ #
24
+ # ==== Examples
25
+ # # Check the default route (i.e., the index action)
26
+ # assert_recognizes({:controller => 'items', :action => 'index'}, 'items')
27
+ #
28
+ # # Test a specific action
29
+ # assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list')
30
+ #
31
+ # # Test an action with a parameter
32
+ # assert_recognizes({:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1')
33
+ #
34
+ # # Test a custom route
35
+ # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1')
36
+ #
37
+ # # Check a Simply RESTful generated route
38
+ # assert_recognizes(list_items_url, 'items/list')
23
39
  def assert_recognizes(expected_options, path, extras={}, message=nil)
24
40
  if path.is_a? Hash
25
41
  request_method = path[:method]
@@ -43,12 +59,24 @@ module ActionController
43
59
  end
44
60
  end
45
61
 
46
- # Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes.
47
- # For example:
62
+ # Asserts that the provided options can be used to generate the provided path. This is the inverse of #assert_recognizes.
63
+ # The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
64
+ # a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
48
65
  #
66
+ # The +defaults+ parameter is unused.
67
+ #
68
+ # ==== Examples
69
+ # # Asserts that the default action is generated for a route with no action
49
70
  # assert_generates("/items", :controller => "items", :action => "index")
71
+ #
72
+ # # Tests that the list action is properly routed
50
73
  # assert_generates("/items/list", :controller => "items", :action => "list")
74
+ #
75
+ # # Tests the generation of a route with a parameter
51
76
  # assert_generates("/items/list/1", { :controller => "items", :action => "list", :id => "1" })
77
+ #
78
+ # # Asserts that the generated route gives us our custom route
79
+ # assert_generates "changesets/12", { :controller => 'scm', :action => 'show_diff', :revision => "12" }
52
80
  def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
53
81
  clean_backtrace do
54
82
  expected_path = "/#{expected_path}" unless expected_path[0] == ?/
@@ -67,9 +95,25 @@ module ActionController
67
95
  end
68
96
  end
69
97
 
70
- # Asserts that path and options match both ways; in other words, the URL generated from
71
- # options is the same as path, and also that the options recognized from path are the same as options. This
72
- # essentially combines assert_recognizes and assert_generates into one step.
98
+ # Asserts that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
99
+ # <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines #assert_recognizes
100
+ # and #assert_generates into one step.
101
+ #
102
+ # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
103
+ # +message+ parameter allows you to specify a custom error message to display upon failure.
104
+ #
105
+ # ==== Examples
106
+ # # Assert a basic route: a controller with the default action (index)
107
+ # assert_routing('/home', :controller => 'home', :action => 'index')
108
+ #
109
+ # # Test a route generated with a specific controller, action, and parameter (id)
110
+ # assert_routing('/entries/show/23', :controller => 'entries', :action => 'show', id => 23)
111
+ #
112
+ # # Assert a basic route (controller + default action), with an error message if it fails
113
+ # assert_routing('/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly')
114
+ #
115
+ # # Tests a route, providing a defaults hash
116
+ # assert_routing 'controller/action/9', {:id => "9", :item => "square"}, {:controller => "controller", :action => "action"}, {}, {:item => "square"}
73
117
  def assert_routing(path, options, defaults={}, extras={}, message=nil)
74
118
  assert_recognizes(options, path, extras, message)
75
119