actionpack 2.0.5 → 2.1.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 (210) hide show
  1. data/CHANGELOG +149 -7
  2. data/MIT-LICENSE +1 -1
  3. data/README +1 -1
  4. data/Rakefile +5 -6
  5. data/lib/action_controller.rb +2 -2
  6. data/lib/action_controller/assertions/model_assertions.rb +2 -1
  7. data/lib/action_controller/assertions/response_assertions.rb +4 -2
  8. data/lib/action_controller/assertions/routing_assertions.rb +3 -3
  9. data/lib/action_controller/assertions/selector_assertions.rb +30 -27
  10. data/lib/action_controller/assertions/tag_assertions.rb +3 -3
  11. data/lib/action_controller/base.rb +103 -129
  12. data/lib/action_controller/benchmarking.rb +3 -3
  13. data/lib/action_controller/caching.rb +41 -652
  14. data/lib/action_controller/caching/actions.rb +144 -0
  15. data/lib/action_controller/caching/fragments.rb +138 -0
  16. data/lib/action_controller/caching/pages.rb +154 -0
  17. data/lib/action_controller/caching/sql_cache.rb +18 -0
  18. data/lib/action_controller/caching/sweeping.rb +97 -0
  19. data/lib/action_controller/cgi_ext/cookie.rb +27 -23
  20. data/lib/action_controller/cgi_ext/stdinput.rb +1 -0
  21. data/lib/action_controller/cgi_process.rb +6 -4
  22. data/lib/action_controller/components.rb +7 -6
  23. data/lib/action_controller/cookies.rb +31 -19
  24. data/lib/action_controller/dispatcher.rb +51 -84
  25. data/lib/action_controller/filters.rb +295 -421
  26. data/lib/action_controller/flash.rb +1 -6
  27. data/lib/action_controller/headers.rb +31 -0
  28. data/lib/action_controller/helpers.rb +26 -9
  29. data/lib/action_controller/http_authentication.rb +1 -1
  30. data/lib/action_controller/integration.rb +65 -13
  31. data/lib/action_controller/layout.rb +24 -39
  32. data/lib/action_controller/mime_responds.rb +7 -3
  33. data/lib/action_controller/mime_type.rb +25 -9
  34. data/lib/action_controller/mime_types.rb +1 -1
  35. data/lib/action_controller/polymorphic_routes.rb +32 -17
  36. data/lib/action_controller/record_identifier.rb +10 -4
  37. data/lib/action_controller/request.rb +46 -30
  38. data/lib/action_controller/request_forgery_protection.rb +10 -9
  39. data/lib/action_controller/request_profiler.rb +29 -8
  40. data/lib/action_controller/rescue.rb +24 -24
  41. data/lib/action_controller/resources.rb +66 -23
  42. data/lib/action_controller/response.rb +2 -2
  43. data/lib/action_controller/routing.rb +113 -1229
  44. data/lib/action_controller/routing/builder.rb +204 -0
  45. data/lib/action_controller/{routing_optimisation.rb → routing/optimisations.rb} +13 -12
  46. data/lib/action_controller/routing/recognition_optimisation.rb +158 -0
  47. data/lib/action_controller/routing/route.rb +240 -0
  48. data/lib/action_controller/routing/route_set.rb +435 -0
  49. data/lib/action_controller/routing/routing_ext.rb +46 -0
  50. data/lib/action_controller/routing/segments.rb +283 -0
  51. data/lib/action_controller/session/active_record_store.rb +13 -8
  52. data/lib/action_controller/session/cookie_store.rb +20 -17
  53. data/lib/action_controller/session_management.rb +10 -3
  54. data/lib/action_controller/streaming.rb +45 -31
  55. data/lib/action_controller/test_case.rb +33 -23
  56. data/lib/action_controller/test_process.rb +39 -35
  57. data/lib/action_controller/url_rewriter.rb +18 -12
  58. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +1 -1
  59. data/lib/action_pack.rb +1 -1
  60. data/lib/action_pack/version.rb +2 -2
  61. data/lib/action_view.rb +11 -3
  62. data/lib/action_view/base.rb +73 -390
  63. data/lib/action_view/helpers/active_record_helper.rb +83 -62
  64. data/lib/action_view/helpers/asset_tag_helper.rb +101 -44
  65. data/lib/action_view/helpers/atom_feed_helper.rb +35 -7
  66. data/lib/action_view/helpers/benchmark_helper.rb +5 -3
  67. data/lib/action_view/helpers/cache_helper.rb +3 -2
  68. data/lib/action_view/helpers/capture_helper.rb +1 -2
  69. data/lib/action_view/helpers/date_helper.rb +104 -82
  70. data/lib/action_view/helpers/form_helper.rb +148 -75
  71. data/lib/action_view/helpers/form_options_helper.rb +44 -23
  72. data/lib/action_view/helpers/form_tag_helper.rb +22 -13
  73. data/lib/action_view/helpers/javascripts/controls.js +1 -1
  74. data/lib/action_view/helpers/javascripts/dragdrop.js +1 -1
  75. data/lib/action_view/helpers/javascripts/effects.js +1 -1
  76. data/lib/action_view/helpers/number_helper.rb +10 -3
  77. data/lib/action_view/helpers/prototype_helper.rb +61 -29
  78. data/lib/action_view/helpers/record_tag_helper.rb +3 -3
  79. data/lib/action_view/helpers/sanitize_helper.rb +23 -17
  80. data/lib/action_view/helpers/scriptaculous_helper.rb +86 -60
  81. data/lib/action_view/helpers/text_helper.rb +153 -125
  82. data/lib/action_view/helpers/url_helper.rb +83 -28
  83. data/lib/action_view/inline_template.rb +20 -0
  84. data/lib/action_view/partial_template.rb +70 -0
  85. data/lib/action_view/partials.rb +31 -73
  86. data/lib/action_view/template.rb +127 -0
  87. data/lib/action_view/template_error.rb +8 -7
  88. data/lib/action_view/template_finder.rb +177 -0
  89. data/lib/action_view/template_handler.rb +18 -1
  90. data/lib/action_view/template_handlers/builder.rb +10 -2
  91. data/lib/action_view/template_handlers/compilable.rb +128 -0
  92. data/lib/action_view/template_handlers/erb.rb +37 -2
  93. data/lib/action_view/template_handlers/rjs.rb +14 -1
  94. data/lib/action_view/test_case.rb +58 -0
  95. data/test/abstract_unit.rb +1 -1
  96. data/test/active_record_unit.rb +3 -6
  97. data/test/activerecord/active_record_store_test.rb +1 -2
  98. data/test/activerecord/render_partial_with_record_identification_test.rb +158 -41
  99. data/test/adv_attr_test.rb +20 -0
  100. data/test/controller/action_pack_assertions_test.rb +16 -19
  101. data/test/controller/addresses_render_test.rb +1 -1
  102. data/test/controller/assert_select_test.rb +13 -6
  103. data/test/controller/base_test.rb +48 -2
  104. data/test/controller/benchmark_test.rb +1 -2
  105. data/test/controller/caching_test.rb +282 -21
  106. data/test/controller/capture_test.rb +1 -1
  107. data/test/controller/cgi_test.rb +1 -1
  108. data/test/controller/components_test.rb +1 -1
  109. data/test/controller/content_type_test.rb +2 -2
  110. data/test/controller/cookie_test.rb +13 -2
  111. data/test/controller/custom_handler_test.rb +14 -10
  112. data/test/controller/deprecation/deprecated_base_methods_test.rb +1 -1
  113. data/test/controller/dispatcher_test.rb +31 -49
  114. data/test/controller/fake_controllers.rb +17 -0
  115. data/test/controller/fake_models.rb +6 -0
  116. data/test/controller/filter_params_test.rb +14 -8
  117. data/test/controller/filters_test.rb +44 -16
  118. data/test/controller/flash_test.rb +2 -2
  119. data/test/controller/header_test.rb +14 -0
  120. data/test/controller/helper_test.rb +19 -15
  121. data/test/controller/html-scanner/document_test.rb +1 -2
  122. data/test/controller/html-scanner/node_test.rb +1 -2
  123. data/test/controller/html-scanner/sanitizer_test.rb +8 -5
  124. data/test/controller/html-scanner/tag_node_test.rb +1 -2
  125. data/test/controller/html-scanner/text_node_test.rb +2 -3
  126. data/test/controller/html-scanner/tokenizer_test.rb +8 -2
  127. data/test/controller/http_authentication_test.rb +1 -1
  128. data/test/controller/integration_test.rb +14 -16
  129. data/test/controller/integration_upload_test.rb +43 -0
  130. data/test/controller/layout_test.rb +26 -6
  131. data/test/controller/mime_responds_test.rb +39 -7
  132. data/test/controller/mime_type_test.rb +29 -5
  133. data/test/controller/new_render_test.rb +105 -34
  134. data/test/controller/polymorphic_routes_test.rb +32 -20
  135. data/test/controller/record_identifier_test.rb +38 -2
  136. data/test/controller/redirect_test.rb +21 -1
  137. data/test/controller/render_test.rb +59 -15
  138. data/test/controller/request_forgery_protection_test.rb +92 -5
  139. data/test/controller/request_test.rb +64 -6
  140. data/test/controller/rescue_test.rb +22 -6
  141. data/test/controller/resources_test.rb +102 -14
  142. data/test/controller/routing_test.rb +231 -19
  143. data/test/controller/selector_test.rb +2 -2
  144. data/test/controller/send_file_test.rb +14 -3
  145. data/test/controller/session/cookie_store_test.rb +16 -4
  146. data/test/controller/session/mem_cache_store_test.rb +3 -4
  147. data/test/controller/session_fixation_test.rb +1 -1
  148. data/test/controller/session_management_test.rb +23 -1
  149. data/test/controller/test_test.rb +39 -18
  150. data/test/controller/url_rewriter_test.rb +35 -1
  151. data/test/controller/verification_test.rb +1 -1
  152. data/test/controller/view_paths_test.rb +15 -12
  153. data/test/controller/webservice_test.rb +48 -3
  154. data/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
  155. data/test/fixtures/company.rb +1 -0
  156. data/test/fixtures/customers/_customer.html.erb +1 -0
  157. data/test/fixtures/db_definitions/sqlite.sql +6 -0
  158. data/test/fixtures/functional_caching/_partial.erb +3 -0
  159. data/test/fixtures/functional_caching/fragment_cached.html.erb +2 -0
  160. data/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
  161. data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +1 -0
  162. data/test/fixtures/good_customers/_good_customer.html.erb +1 -0
  163. data/test/fixtures/mascot.rb +3 -0
  164. data/test/fixtures/mascots.yml +4 -0
  165. data/test/fixtures/mascots/_mascot.html.erb +1 -0
  166. data/test/fixtures/multipart/boundary_problem_file +10 -0
  167. data/test/fixtures/public/javascripts/application.js +1 -0
  168. data/test/fixtures/public/javascripts/controls.js +1 -0
  169. data/test/fixtures/public/javascripts/dragdrop.js +1 -0
  170. data/test/fixtures/public/javascripts/effects.js +1 -0
  171. data/test/fixtures/public/javascripts/prototype.js +1 -0
  172. data/test/fixtures/public/javascripts/version.1.0.js +1 -0
  173. data/test/fixtures/public/stylesheets/version.1.0.css +1 -0
  174. data/test/fixtures/reply.rb +1 -0
  175. data/test/fixtures/shared.html.erb +1 -0
  176. data/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
  177. data/test/fixtures/test/_customer_counter.erb +1 -0
  178. data/test/fixtures/test/_form.erb +1 -0
  179. data/test/fixtures/test/_labelling_form.erb +1 -0
  180. data/test/fixtures/test/_raise.html.erb +1 -0
  181. data/test/fixtures/test/greeting.js.rjs +1 -0
  182. data/test/fixtures/topics/_topic.html.erb +1 -0
  183. data/test/template/active_record_helper_test.rb +25 -8
  184. data/test/template/asset_tag_helper_test.rb +100 -17
  185. data/test/template/atom_feed_helper_test.rb +29 -1
  186. data/test/template/benchmark_helper_test.rb +10 -22
  187. data/test/template/date_helper_test.rb +455 -153
  188. data/test/template/erb_util_test.rb +10 -42
  189. data/test/template/form_helper_test.rb +192 -66
  190. data/test/template/form_options_helper_test.rb +19 -8
  191. data/test/template/form_tag_helper_test.rb +11 -8
  192. data/test/template/javascript_helper_test.rb +3 -9
  193. data/test/template/number_helper_test.rb +6 -3
  194. data/test/template/prototype_helper_test.rb +27 -40
  195. data/test/template/record_tag_helper_test.rb +54 -0
  196. data/test/template/sanitize_helper_test.rb +5 -6
  197. data/test/template/scriptaculous_helper_test.rb +7 -13
  198. data/test/template/tag_helper_test.rb +3 -6
  199. data/test/template/template_finder_test.rb +73 -0
  200. data/test/template/template_object_test.rb +95 -0
  201. data/test/template/test_test.rb +56 -0
  202. data/test/template/text_helper_test.rb +46 -33
  203. data/test/template/url_helper_test.rb +8 -10
  204. metadata +65 -12
  205. data/lib/action_view/compiled_templates.rb +0 -69
  206. data/test/action_view_test.rb +0 -44
  207. data/test/activerecord/fixtures_test.rb +0 -24
  208. data/test/controller/fragment_store_setting_test.rb +0 -47
  209. data/test/template/compiled_templates_test.rb +0 -197
  210. data/test/template/deprecate_ivars_test.rb +0 -51
data/CHANGELOG CHANGED
@@ -1,16 +1,116 @@
1
- *2.0.5* (October 19th, 2008)
1
+ *2.1.0 (May 31st, 2008)*
2
2
 
3
- * Sanitize the URLs passed to redirect_to to prevent a potential response splitting attack [koz]
3
+ * InstanceTag#default_time_from_options overflows to DateTime [Geoff Buesing]
4
4
 
5
+ * Fixed that forgery protection can be used without session tracking (Peter Jones) [#139]
5
6
 
6
- *2.0.4* (2nd September 2008)
7
+ * Added session(:on) to turn session management back on in a controller subclass if the superclass turned it off (Peter Jones) [#136]
8
+
9
+ * Change the request forgery protection to go by Content-Type instead of request.format so that you can't bypass it by POSTing to "#{request.uri}.xml" [rick]
10
+ * InstanceTag#default_time_from_options with hash args uses Time.current as default; respects hash settings when time falls in system local spring DST gap [Geoff Buesing]
11
+
12
+ * select_date defaults to Time.zone.today when config.time_zone is set [Geoff Buesing]
13
+
14
+ * Fixed that TextHelper#text_field would corrypt when raw HTML was used as the value (mchenryc, Kevin Glowacz) [#80]
15
+
16
+ * Added ActionController::TestCase#rescue_action_in_public! to control whether the action under test should use the regular rescue_action path instead of simply raising the exception inline (great for error testing) [DHH]
17
+
18
+ * Reduce number of instance variables being copied from controller to view. [Pratik]
19
+
20
+ * select_datetime and select_time default to Time.zone.now when config.time_zone is set [Geoff Buesing]
21
+
22
+ * datetime_select defaults to Time.zone.now when config.time_zone is set [Geoff Buesing]
23
+
24
+ * Remove ActionController::Base#view_controller_internals flag. [Pratik]
25
+
26
+ * Add conditional options to caches_page method. [Paul Horsfall]
27
+
28
+ * Move missing template logic to ActionView. [Pratik]
29
+
30
+ * Introduce ActionView::InlineTemplate class. [Pratik]
31
+
32
+ * Automatically parse posted JSON content for Mime::JSON requests. [rick]
33
+
34
+ POST /posts
35
+ {"post": {"title": "Breaking News"}}
36
+
37
+ def create
38
+ @post = Post.create params[:post]
39
+ # ...
40
+ end
41
+
42
+ * add json_escape ERB util to escape html entities in json strings that are output in HTML pages. [rick]
43
+
44
+ * Provide a helper proxy to access helper methods from outside views. Closes #10839 [Josh Peek]
45
+ e.g. ApplicationController.helpers.simple_format(text)
46
+
47
+ * Improve documentation. [Xavier Noria, leethal, jerome]
48
+
49
+ * Ensure RJS redirect_to doesn't html-escapes string argument. Closes #8546 [josh, eventualbuddha, Pratik]
50
+
51
+ * Support render :partial => collection of heterogeneous elements. #11491 [Zach Dennis]
7
52
 
8
53
  * Avoid remote_ip spoofing. [Brian Candler]
9
54
 
10
- * Correct inconsistencies in RequestForgeryProtection docs. #11032 [mislav]
55
+ * Added support for regexp flags like ignoring case in the :requirements part of routes declarations #11421 [NeilW]
11
56
 
12
- * Make assert_routing aware of the HTTP method used. #8039 [mpalmer]
13
- e.g. assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" })
57
+ * Fixed that ActionController::Base#read_multipart would fail if boundary was exactly 10240 bytes #10886 [ariejan]
58
+
59
+ * Fixed HTML::Tokenizer (used in sanitize helper) didn't handle unclosed CDATA tags #10071 [esad, packagethief]
60
+
61
+ * Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
62
+
63
+ * Fixed that FormHelper#radio_button would produce invalid ids #11298 [harlancrystal]
64
+
65
+ * Added :confirm option to submit_tag #11415 [miloops]
66
+
67
+ * Fixed NumberHelper#number_with_precision to properly round in a way that works equally on Mac, Windows, Linux (closes #11409, #8275, #10090, #8027) [zhangyuanyi]
68
+
69
+ * Allow the #simple_format text_helper to take an html_options hash for each paragraph. #2448 [Francois Beausoleil, thechrisoshow]
70
+
71
+ * Fix regression from filter refactoring where re-adding a skipped filter resulted in it being called twice. [rick]
72
+
73
+ * Refactor filters to use Active Support callbacks. #11235 [Josh Peek]
74
+
75
+ * Fixed that polymorphic routes would modify the input array #11363 [thomas.lee]
76
+
77
+ * Added :format option to NumberHelper#number_to_currency to enable better localization support #11149 [lylo]
78
+
79
+ * Fixed that TextHelper#excerpt would include one character too many #11268 [Irfy]
80
+
81
+ * Fix more obscure nested parameter hash parsing bug. #10797 [thomas.lee]
82
+
83
+ * Added ActionView::Helpers::register_javascript/stylesheet_expansion to make it easier for plugin developers to inject multiple assets. #10350 [lotswholetime]
84
+
85
+ * Fix nested parameter hash parsing bug. #10797 [thomas.lee]
86
+
87
+ * Allow using named routes in ActionController::TestCase before any request has been made. Closes #11273 [alloy]
88
+
89
+ * Fixed that sweepers defined by cache_sweeper will be added regardless of the perform_caching setting. Instead, control whether the sweeper should be run with the perform_caching setting. This makes testing easier when you want to turn perform_caching on/off [DHH]
90
+
91
+ * Make MimeResponds::Responder#any work without explicit types. Closes #11140 [jaw6]
92
+
93
+ * Better error message for type conflicts when parsing params. Closes #7962 [spicycode, matt]
94
+
95
+ * Remove unused ActionController::Base.template_class. Closes #10787 [Pratik]
96
+
97
+ * Moved template handlers related code from ActionView::Base to ActionView::Template. [Pratik]
98
+
99
+ * Tests for div_for and content_tag_for helpers. Closes #11223 [thechrisoshow]
100
+
101
+ * Allow file uploads in Integration Tests. Closes #11091 [RubyRedRick]
102
+
103
+ * Refactor partial rendering into a PartialTemplate class. [Pratik]
104
+
105
+ * Added that requests with JavaScript as the priority mime type in the accept header and no format extension in the parameters will be treated as though their format was :js when it comes to determining which template to render. This makes it possible for JS requests to automatically render action.js.rjs files without an explicit respond_to block [DHH]
106
+
107
+ * Tests for distance_of_time_in_words with TimeWithZone instances. Closes #10914 [ernesto.jimenez]
108
+
109
+ * Remove support for multivalued (e.g., '&'-delimited) cookies. [Jamis Buck]
110
+
111
+ * Fix problem with render :partial collections, records, and locals. #11057 [lotswholetime]
112
+
113
+ * Added support for naming concrete classes in sweeper declarations [DHH]
14
114
 
15
115
  * Remove ERB trim variables from trace template in case ActionView::Base.erb_trim_mode is changed in the application. #10098 [tpope, kampers]
16
116
 
@@ -18,16 +118,58 @@
18
118
 
19
119
  * Fix bug with setting Request#format= after the getter has cached the value. #10889 [cch1]
20
120
 
21
- * Add label_tag helper for generating elements. #10802 [DefV]
121
+ * Correct inconsistencies in RequestForgeryProtection docs. #11032 [mislav]
122
+
123
+ * Introduce a Template class to ActionView. #11024 [lifofifo]
124
+
125
+ * Introduce the :index option for form_for and fields_for to simplify multi-model forms (see http://railscasts.com/episodes/75). #9883 [rmm5t]
126
+
127
+ * Introduce map.resources :cards, :as => 'tarjetas' to use a custom resource name in the URL: cards_path == '/tarjetas'. #10578 [blj]
22
128
 
23
129
  * TestSession supports indifferent access. #7372 [tamc, Arsen7, mhackett, julik, jean.helou]
24
130
 
131
+ * Make assert_routing aware of the HTTP method used. #8039 [mpalmer]
132
+ e.g. assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" })
133
+
134
+ * Make map.root accept a single symbol as an argument to declare an alias. #10818 [bscofield]
135
+
136
+ e.g. map.dashboard '/dashboard', :controller=>'dashboard'
137
+ map.root :dashboard
138
+
139
+ * Handle corner case with image_tag when passed 'messed up' image names. #9018 [duncanbeevers, mpalmer]
140
+
141
+ * Add label_tag helper for generating elements. #10802 [DefV]
142
+
143
+ * Introduce TemplateFinder to handle view paths and lookups. #10800 [Pratik Naik]
144
+
145
+ * Performance: optimize route recognition. Large speedup for apps with many resource routes. #10835 [oleganza]
146
+
147
+ * Make render :partial recognise form builders and use the _form partial. #10814 [djanowski]
148
+
149
+ * Allow users to declare other namespaces when using the atom feed helpers. #10304 [david.calavera]
150
+
151
+ * Introduce send_file :x_sendfile => true to send an X-Sendfile response header. [Jeremy Kemper]
152
+
153
+ * Fixed ActionView::Helpers::ActiveRecordHelper::form for when protect_from_forgery is used #10739 [jeremyevans]
154
+
155
+ * Provide nicer access to HTTP Headers. Instead of request.env["HTTP_REFERRER"] you can now use request.headers["Referrer"]. [Koz]
156
+
25
157
  * UrlWriter respects relative_url_root. #10748 [Cheah Chu Yeow]
26
158
 
159
+ * The asset_host block takes the controller request as an optional second argument. Example: use a single asset host for SSL requests. #10549 [Cheah Chu Yeow, Peter B, Tom Taylor]
160
+
27
161
  * Support render :text => nil. #6684 [tjennings, PotatoSalad, Cheah Chu Yeow]
28
162
 
29
163
  * assert_response failures include the exception message. #10688 [Seth Rasmussen]
30
164
 
165
+ * All fragment cache keys are now by default prefixed with the "views/" namespace [DHH]
166
+
167
+ * Moved the caching stores from ActionController::Caching::Fragments::* to ActiveSupport::Cache::*. If you're explicitly referring to a store, like ActionController::Caching::Fragments::MemoryStore, you need to update that reference with ActiveSupport::Cache::MemoryStore [DHH]
168
+
169
+ * Deprecated ActionController::Base.fragment_cache_store for ActionController::Base.cache_store [DHH]
170
+
171
+ * Made fragment caching in views work for rjs and builder as well #6642 [zsombor]
172
+
31
173
  * Fixed rendering of partials with layout when done from site layout #9209 [antramm]
32
174
 
33
175
  * Fix atom_feed_helper to comply with the atom spec. Closes #10672 [xaviershay]
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2007 David Heinemeier Hansson
1
+ Copyright (c) 2004-2008 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
@@ -97,7 +97,7 @@ A short rundown of the major features:
97
97
 
98
98
  class WeblogController < ActionController::Base
99
99
  before_filter :authenticate, :cache, :audit
100
- after_filter { |c| c.response.body = GZip::compress(c.response.body) }
100
+ after_filter { |c| c.response.body = Gzip::compress(c.response.body) }
101
101
  after_filter LocalizeFilter
102
102
 
103
103
  def index
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'rake/rdoctask'
5
5
  require 'rake/packagetask'
6
6
  require 'rake/gempackagetask'
7
7
  require 'rake/contrib/sshpublisher'
8
- require 'rake/contrib/rubyforgepublisher'
9
8
  require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
10
9
 
11
10
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
@@ -28,9 +27,9 @@ task :test => [:test_action_pack, :test_active_record_integration]
28
27
 
29
28
  Rake::TestTask.new(:test_action_pack) { |t|
30
29
  t.libs << "test"
31
- # make sure we include the controller tests (c*) first as on some systems
30
+ # make sure we include the tests in alphabetical order as on some systems
32
31
  # this will not happen automatically and the tests (as a whole) will error
33
- t.test_files=Dir.glob( "test/c*/**/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" )
32
+ t.test_files=Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
34
33
  # t.pattern = 'test/*/*_test.rb'
35
34
  t.verbose = true
36
35
  }
@@ -77,7 +76,7 @@ spec = Gem::Specification.new do |s|
77
76
  s.has_rdoc = true
78
77
  s.requirements << 'none'
79
78
 
80
- s.add_dependency('activesupport', '= 2.0.5' + PKG_BUILD)
79
+ s.add_dependency('activesupport', '= 2.1.0' + PKG_BUILD)
81
80
 
82
81
  s.require_path = 'lib'
83
82
  s.autorequire = 'action_controller'
@@ -133,8 +132,8 @@ task :update_js => [ :update_scriptaculous ]
133
132
 
134
133
  desc "Publish the API documentation"
135
134
  task :pgem => [:package] do
136
- Rake::SshFilePublisher.new("david@greed.loudthinking.com", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
137
- `ssh david@greed.loudthinking.com '/u/sites/gems/gemupdate.sh'`
135
+ Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
136
+ `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
138
137
  end
139
138
 
140
139
  desc "Publish the API documentation"
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2007 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2008 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
@@ -55,9 +55,9 @@ require 'action_controller/http_authentication'
55
55
  require 'action_controller/components'
56
56
  require 'action_controller/record_identifier'
57
57
  require 'action_controller/request_forgery_protection'
58
+ require 'action_controller/headers'
58
59
 
59
60
  require 'action_view'
60
- ActionController::Base.template_class = ActionView::Base
61
61
 
62
62
  ActionController::Base.class_eval do
63
63
  include ActionController::Flash
@@ -1,7 +1,8 @@
1
1
  module ActionController
2
2
  module Assertions
3
3
  module ModelAssertions
4
- # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not.
4
+ # Ensures that the passed record is valid by Active Record standards and
5
+ # returns any error messages if it is not.
5
6
  #
6
7
  # ==== Examples
7
8
  #
@@ -34,7 +34,9 @@ module ActionController
34
34
  assert_block("") { true } # to count the assertion
35
35
  else
36
36
  if @response.error?
37
- assert_block(build_message(message, "Expected response to be a <?>, but was <?>\n<?>", type, @response.response_code, @response.template.instance_variable_get(:@exception).message)) { false }
37
+ exception = @response.template.instance_variable_get(:@exception)
38
+ exception_message = exception && exception.message
39
+ assert_block(build_message(message, "Expected response to be a <?>, but was <?>\n<?>", type, @response.response_code, exception_message.to_s)) { false }
38
40
  else
39
41
  assert_block(build_message(message, "Expected response to be a <?>, but was <?>", type, @response.response_code)) { false }
40
42
  end
@@ -95,7 +97,7 @@ module ActionController
95
97
  value['controller'] = value['controller'].to_s
96
98
  if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
97
99
  new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
98
- value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash)
100
+ value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path)
99
101
  end
100
102
  value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash
101
103
  end
@@ -59,7 +59,7 @@ module ActionController
59
59
  end
60
60
  end
61
61
 
62
- # Asserts that the provided options can be used to generate the provided path. This is the inverse of #assert_recognizes.
62
+ # Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
63
63
  # The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
64
64
  # a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
65
65
  #
@@ -96,8 +96,8 @@ module ActionController
96
96
  end
97
97
 
98
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.
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
101
  #
102
102
  # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
103
103
  # +message+ parameter allows you to specify a custom error message to display upon failure.
@@ -12,20 +12,20 @@ module ActionController
12
12
  NO_STRIP = %w{pre script style textarea}
13
13
  end
14
14
 
15
- # Adds the #assert_select method for use in Rails functional
15
+ # Adds the +assert_select+ method for use in Rails functional
16
16
  # test cases, which can be used to make assertions on the response HTML of a controller
17
- # action. You can also call #assert_select within another #assert_select to
17
+ # action. You can also call +assert_select+ within another +assert_select+ to
18
18
  # make assertions on elements selected by the enclosing assertion.
19
19
  #
20
- # Use #css_select to select elements without making an assertions, either
20
+ # Use +css_select+ to select elements without making an assertions, either
21
21
  # from the response HTML or elements selected by the enclosing assertion.
22
22
  #
23
23
  # In addition to HTML responses, you can make the following assertions:
24
- # * #assert_select_rjs -- Assertions on HTML content of RJS update and
24
+ # * +assert_select_rjs+ - Assertions on HTML content of RJS update and
25
25
  # insertion operations.
26
- # * #assert_select_encoded -- Assertions on HTML encoded inside XML,
26
+ # * +assert_select_encoded+ - Assertions on HTML encoded inside XML,
27
27
  # for example for dealing with feed item descriptions.
28
- # * #assert_select_email -- Assertions on the HTML body of an e-mail.
28
+ # * +assert_select_email+ - Assertions on the HTML body of an e-mail.
29
29
  #
30
30
  # Also see HTML::Selector to learn how to use selectors.
31
31
  module SelectorAssertions
@@ -44,8 +44,8 @@ module ActionController
44
44
  # base element and any of its children. Returns an empty array if no
45
45
  # match is found.
46
46
  #
47
- # The selector may be a CSS selector expression (+String+), an expression
48
- # with substitution values (+Array+) or an HTML::Selector object.
47
+ # The selector may be a CSS selector expression (String), an expression
48
+ # with substitution values (Array) or an HTML::Selector object.
49
49
  #
50
50
  # ==== Examples
51
51
  # # Selects all div tags
@@ -114,8 +114,8 @@ module ActionController
114
114
  # starting from (and including) that element and all its children in
115
115
  # depth-first order.
116
116
  #
117
- # If no element if specified, calling #assert_select will select from the
118
- # response HTML. Calling #assert_select inside an #assert_select block will
117
+ # If no element if specified, calling +assert_select+ will select from the
118
+ # response HTML. Calling #assert_select inside an +assert_select+ block will
119
119
  # run the assertion for each element selected by the enclosing assertion.
120
120
  #
121
121
  # ==== Example
@@ -130,33 +130,33 @@ module ActionController
130
130
  # assert_select "li"
131
131
  # end
132
132
  #
133
- # The selector may be a CSS selector expression (+String+), an expression
133
+ # The selector may be a CSS selector expression (String), an expression
134
134
  # with substitution values, or an HTML::Selector object.
135
135
  #
136
136
  # === Equality Tests
137
137
  #
138
138
  # The equality test may be one of the following:
139
- # * <tt>true</tt> -- Assertion is true if at least one element selected.
140
- # * <tt>false</tt> -- Assertion is true if no element selected.
141
- # * <tt>String/Regexp</tt> -- Assertion is true if the text value of at least
139
+ # * <tt>true</tt> - Assertion is true if at least one element selected.
140
+ # * <tt>false</tt> - Assertion is true if no element selected.
141
+ # * <tt>String/Regexp</tt> - Assertion is true if the text value of at least
142
142
  # one element matches the string or regular expression.
143
- # * <tt>Integer</tt> -- Assertion is true if exactly that number of
143
+ # * <tt>Integer</tt> - Assertion is true if exactly that number of
144
144
  # elements are selected.
145
- # * <tt>Range</tt> -- Assertion is true if the number of selected
145
+ # * <tt>Range</tt> - Assertion is true if the number of selected
146
146
  # elements fit the range.
147
147
  # If no equality test specified, the assertion is true if at least one
148
148
  # element selected.
149
149
  #
150
150
  # To perform more than one equality tests, use a hash with the following keys:
151
- # * <tt>:text</tt> -- Narrow the selection to elements that have this text
151
+ # * <tt>:text</tt> - Narrow the selection to elements that have this text
152
152
  # value (string or regexp).
153
- # * <tt>:html</tt> -- Narrow the selection to elements that have this HTML
153
+ # * <tt>:html</tt> - Narrow the selection to elements that have this HTML
154
154
  # content (string or regexp).
155
- # * <tt>:count</tt> -- Assertion is true if the number of selected elements
155
+ # * <tt>:count</tt> - Assertion is true if the number of selected elements
156
156
  # is equal to this value.
157
- # * <tt>:minimum</tt> -- Assertion is true if the number of selected
157
+ # * <tt>:minimum</tt> - Assertion is true if the number of selected
158
158
  # elements is at least this value.
159
- # * <tt>:maximum</tt> -- Assertion is true if the number of selected
159
+ # * <tt>:maximum</tt> - Assertion is true if the number of selected
160
160
  # elements is at most this value.
161
161
  #
162
162
  # If the method is called with a block, once all equality tests are
@@ -263,12 +263,15 @@ module ActionController
263
263
  if match_with = equals[:text]
264
264
  matches.delete_if do |match|
265
265
  text = ""
266
+ text.force_encoding(match_with.encoding) if text.respond_to?(:force_encoding)
266
267
  stack = match.children.reverse
267
268
  while node = stack.pop
268
269
  if node.tag?
269
270
  stack.concat node.children.reverse
270
271
  else
271
- text << node.content
272
+ content = node.content
273
+ content.force_encoding(match_with.encoding) if content.respond_to?(:force_encoding)
274
+ text << content
272
275
  end
273
276
  end
274
277
  text.strip! unless NO_STRIP.include?(match.name)
@@ -353,16 +356,16 @@ module ActionController
353
356
  #
354
357
  # === Using blocks
355
358
  #
356
- # Without a block, #assert_select_rjs merely asserts that the response
359
+ # Without a block, +assert_select_rjs+ merely asserts that the response
357
360
  # contains one or more RJS statements that replace or update content.
358
361
  #
359
- # With a block, #assert_select_rjs also selects all elements used in
362
+ # With a block, +assert_select_rjs+ also selects all elements used in
360
363
  # these statements and passes them to the block. Nested assertions are
361
364
  # supported.
362
365
  #
363
- # Calling #assert_select_rjs with no arguments and using nested asserts
366
+ # Calling +assert_select_rjs+ with no arguments and using nested asserts
364
367
  # asserts that the HTML content is returned by one or more RJS statements.
365
- # Using #assert_select directly makes the same assertion on the content,
368
+ # Using +assert_select+ directly makes the same assertion on the content,
366
369
  # but without distinguishing whether the content is returned in an HTML
367
370
  # or JavaScript.
368
371
  #
@@ -598,7 +601,7 @@ module ActionController
598
601
  RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
599
602
  end
600
603
 
601
- # #assert_select and #css_select call this to obtain the content in the HTML
604
+ # +assert_select+ and +css_select+ call this to obtain the content in the HTML
602
605
  # page, or from all the RJS statements, depending on the type of response.
603
606
  def response_from_page_or_rjs()
604
607
  content_type = @response.content_type
@@ -91,7 +91,7 @@ module ActionController
91
91
  # :descendant => { :tag => "span",
92
92
  # :child => /hello world/ }
93
93
  #
94
- # <b>Please note</b>: #assert_tag and #assert_no_tag only work
94
+ # <b>Please note</b>: +assert_tag+ and +assert_no_tag+ only work
95
95
  # with well-formed XHTML. They recognize a few tags as implicitly self-closing
96
96
  # (like br and hr and such) but will not work correctly with tags
97
97
  # that allow optional closing tags (p, li, td). <em>You must explicitly
@@ -104,8 +104,8 @@ module ActionController
104
104
  end
105
105
  end
106
106
 
107
- # Identical to #assert_tag, but asserts that a matching tag does _not_
108
- # exist. (See #assert_tag for a full discussion of the syntax.)
107
+ # Identical to +assert_tag+, but asserts that a matching tag does _not_
108
+ # exist. (See +assert_tag+ for a full discussion of the syntax.)
109
109
  #
110
110
  # === Examples
111
111
  # # Assert that there is not a "div" containing a "p"