actionpack 1.8.1 → 1.9.0

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

Potentially problematic release.


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

Files changed (101) hide show
  1. data/CHANGELOG +309 -16
  2. data/README +1 -1
  3. data/lib/action_controller.rb +5 -0
  4. data/lib/action_controller/assertions.rb +57 -12
  5. data/lib/action_controller/auto_complete.rb +47 -0
  6. data/lib/action_controller/base.rb +288 -258
  7. data/lib/action_controller/benchmarking.rb +8 -3
  8. data/lib/action_controller/caching.rb +88 -42
  9. data/lib/action_controller/cgi_ext/cgi_ext.rb +1 -1
  10. data/lib/action_controller/cgi_ext/cgi_methods.rb +41 -11
  11. data/lib/action_controller/cgi_ext/multipart_progress.rb +169 -0
  12. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +30 -12
  13. data/lib/action_controller/cgi_process.rb +39 -11
  14. data/lib/action_controller/code_generation.rb +235 -0
  15. data/lib/action_controller/cookies.rb +14 -8
  16. data/lib/action_controller/deprecated_renders_and_redirects.rb +76 -0
  17. data/lib/action_controller/filters.rb +8 -7
  18. data/lib/action_controller/helpers.rb +41 -6
  19. data/lib/action_controller/layout.rb +45 -16
  20. data/lib/action_controller/request.rb +86 -23
  21. data/lib/action_controller/rescue.rb +1 -0
  22. data/lib/action_controller/response.rb +1 -1
  23. data/lib/action_controller/routing.rb +536 -272
  24. data/lib/action_controller/scaffolding.rb +30 -25
  25. data/lib/action_controller/session/active_record_store.rb +251 -50
  26. data/lib/action_controller/streaming.rb +133 -0
  27. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -7
  28. data/lib/action_controller/templates/scaffolds/edit.rhtml +2 -2
  29. data/lib/action_controller/templates/scaffolds/layout.rhtml +22 -18
  30. data/lib/action_controller/templates/scaffolds/list.rhtml +3 -3
  31. data/lib/action_controller/templates/scaffolds/new.rhtml +2 -2
  32. data/lib/action_controller/templates/scaffolds/show.rhtml +1 -1
  33. data/lib/action_controller/test_process.rb +68 -47
  34. data/lib/action_controller/upload_progress.rb +421 -0
  35. data/lib/action_controller/url_rewriter.rb +8 -11
  36. data/lib/action_controller/vendor/html-scanner/html/document.rb +6 -5
  37. data/lib/action_controller/vendor/html-scanner/html/node.rb +70 -14
  38. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +17 -10
  39. data/lib/action_controller/vendor/html-scanner/html/version.rb +3 -3
  40. data/lib/action_controller/vendor/xml_simple.rb +1019 -0
  41. data/lib/action_controller/verification.rb +36 -30
  42. data/lib/action_view/base.rb +21 -14
  43. data/lib/action_view/helpers/active_record_helper.rb +15 -13
  44. data/lib/action_view/helpers/asset_tag_helper.rb +26 -9
  45. data/lib/action_view/helpers/benchmark_helper.rb +24 -0
  46. data/lib/action_view/helpers/capture_helper.rb +7 -5
  47. data/lib/action_view/helpers/date_helper.rb +63 -46
  48. data/lib/action_view/helpers/form_helper.rb +7 -1
  49. data/lib/action_view/helpers/form_options_helper.rb +19 -11
  50. data/lib/action_view/helpers/form_tag_helper.rb +5 -1
  51. data/lib/action_view/helpers/javascript_helper.rb +403 -35
  52. data/lib/action_view/helpers/javascripts/controls.js +261 -0
  53. data/lib/action_view/helpers/javascripts/dragdrop.js +476 -0
  54. data/lib/action_view/helpers/javascripts/effects.js +570 -0
  55. data/lib/action_view/helpers/javascripts/prototype.js +633 -371
  56. data/lib/action_view/helpers/number_helper.rb +11 -13
  57. data/lib/action_view/helpers/tag_helper.rb +1 -2
  58. data/lib/action_view/helpers/text_helper.rb +69 -6
  59. data/lib/action_view/helpers/upload_progress_helper.rb +433 -0
  60. data/lib/action_view/helpers/url_helper.rb +98 -3
  61. data/lib/action_view/partials.rb +14 -8
  62. data/lib/action_view/vendor/builder/xmlmarkup.rb +11 -0
  63. data/rakefile +13 -5
  64. data/test/abstract_unit.rb +1 -1
  65. data/test/controller/action_pack_assertions_test.rb +52 -9
  66. data/test/controller/active_record_assertions_test.rb +119 -120
  67. data/test/controller/active_record_store_test.rb +111 -0
  68. data/test/controller/addresses_render_test.rb +45 -0
  69. data/test/controller/caching_filestore.rb +92 -0
  70. data/test/controller/capture_test.rb +39 -0
  71. data/test/controller/cgi_test.rb +40 -3
  72. data/test/controller/helper_test.rb +65 -13
  73. data/test/controller/multipart_progress_testx.rb +365 -0
  74. data/test/controller/new_render_test.rb +263 -0
  75. data/test/controller/redirect_test.rb +64 -0
  76. data/test/controller/render_test.rb +20 -21
  77. data/test/controller/request_test.rb +83 -3
  78. data/test/controller/routing_test.rb +702 -0
  79. data/test/controller/send_file_test.rb +2 -0
  80. data/test/controller/test_test.rb +44 -8
  81. data/test/controller/upload_progress_testx.rb +89 -0
  82. data/test/controller/verification_test.rb +94 -29
  83. data/test/fixtures/addresses/list.rhtml +1 -0
  84. data/test/fixtures/test/capturing.rhtml +4 -0
  85. data/test/fixtures/test/list.rhtml +1 -1
  86. data/test/fixtures/test/update_element_with_capture.rhtml +9 -0
  87. data/test/template/active_record_helper_test.rb +30 -15
  88. data/test/template/asset_tag_helper_test.rb +12 -5
  89. data/test/template/benchmark_helper_test.rb +72 -0
  90. data/test/template/date_helper_test.rb +69 -0
  91. data/test/template/form_helper_test.rb +18 -10
  92. data/test/template/form_options_helper_test.rb +40 -5
  93. data/test/template/javascript_helper.rb +149 -2
  94. data/test/template/number_helper_test.rb +2 -0
  95. data/test/template/tag_helper_test.rb +4 -0
  96. data/test/template/text_helper_test.rb +36 -0
  97. data/test/template/upload_progress_helper_testx.rb +272 -0
  98. data/test/template/url_helper_test.rb +30 -0
  99. metadata +30 -6
  100. data/test/controller/layout_test.rb +0 -49
  101. data/test/controller/routing_tests.rb +0 -543
data/CHANGELOG CHANGED
@@ -1,3 +1,296 @@
1
+ *1.9.0* (6 July, 2005)
2
+
3
+ * Added logging of the request URI in the benchmark statement (makes it easy to grep for slow actions)
4
+
5
+ * Added javascript_include_tag :defaults shortcut that'll include all the default javascripts included with Action Pack (prototype, effects, controls, dragdrop)
6
+
7
+ * Cache several controller variables that are expensive to calculate #1229 [skaes@web.de]
8
+
9
+ * The session class backing CGI::Session::ActiveRecordStore may be replaced with any class that duck-types with a subset of Active Record. See docs for details #1238 [skaes@web.de]
10
+
11
+ * Fixed that hashes was not working properly when passed by GET to lighttpd #849 [Nicholas Seckar]
12
+
13
+ * Fixed assert_template nil will be true when no template was rendered #1565 [maceywj@telus.net]
14
+
15
+ * Added :prompt option to FormOptions#select (and the users of it, like FormOptions#select_country etc) to create "Please select" style descriptors #1181 [Michael Schuerig]
16
+
17
+ * Added JavascriptHelper#update_element_function, which returns a Javascript function (or expression) that'll update a DOM element according to the options passed #933 [mortonda@dgrmm.net]. Examples:
18
+
19
+ <%= update_element_function("products", :action => :insert, :position => :bottom, :content => "<p>New product!</p>") %>
20
+
21
+ <% update_element_function("products", :action => :replace, :binding => binding) do %>
22
+ <p>Product 1</p>
23
+ <p>Product 2</p>
24
+ <% end %>
25
+
26
+ * Added :field_name option to DateHelper#select_(year|month|day) to deviate from the year/month/day defaults #1266 [Marcel Molina]
27
+
28
+ * Added JavascriptHelper#draggable_element and JavascriptHelper#drop_receiving_element to facilitate easy dragging and dropping through the script.aculo.us libraries #1578 [Thomas Fuchs]
29
+
30
+ * Added that UrlHelper#mail_to will now also encode the default link title #749 [f.svehla@gmail.com]
31
+
32
+ * Removed the default option of wrap=virtual on FormHelper#text_area to ensure XHTML compatibility #1300 [thomas@columbus.rr.com]
33
+
34
+ * Adds the ability to include XML CDATA tags using Builder #1563 [Josh Knowles]. Example:
35
+
36
+ xml.cdata! "some text" # => <![CDATA[some text]]>
37
+
38
+ * Added evaluation of <SCRIPT> blocks in content returned to Ajax calls #1577 [Thomas Fuchs/court3nay/Sean Treadway]
39
+
40
+ * Directly generate paths with a leading slash instead of tacking it on later. #1543 [Nicholas Seckar]
41
+
42
+ * Fixed errant parameter modification in functional tests. #1542 [Nicholas Seckar]
43
+
44
+ * Routes fail with leading slash #1540 [Nicholas Seckar]
45
+
46
+ * Added support for graceful error handling of Ajax calls #1217 [Jamis Buck/Thomas Fuchs]. Example:
47
+
48
+ link_to_remote(
49
+ "test",
50
+ :url => { :action => "faulty" },
51
+ :update => { :success => "good", :failure => "bad" },
52
+ 403 => "alert('Forbidden- got ya!')",
53
+ 404 => "alert('Nothing there...?')",
54
+ :failure => "alert('Unkown error ' + request.status)")
55
+
56
+ * Attempt to explicitly flush the output at the end of CgiProcess#out
57
+
58
+ * Fixed assert_redirected_to to handle absolute controller paths properly #1472 [Rick Olson/Nicholas Seckar]
59
+
60
+ * Added event-based observations when frequency is not set on observe_field/form #1474 [flash@vanklinkenbergsoftware.nl]
61
+
62
+ * Added script.aculo.us Javascripts (controls.js, dragdrop.js, effects.js) (NEEDS MORE DESCRIPTION) #1509 [Thomas Fuchs]
63
+
64
+ * Fixed prototype to consider all fields it doesn't know as text (such as Safari's search) just like the browser in its serialization #1497 [Sean Treadway]
65
+
66
+ * Improved performance of Routes generation by a factor of 5 #1434 [Nicholas Seckar]
67
+
68
+ * Added named routes (NEEDS BETTER DESCRIPTION) #1434 [Nicholas Seckar]
69
+
70
+ * Improved AbstractRequest documentation #1483 [court3nay@gmail.com]
71
+
72
+ * Added ActionController::Base.allow_concurrency to control whether the application is thread-safe, so multi-threaded servers like WEBrick knows whether to apply a mutex around the performance of each action. Turned off by default. EXPERIMENTAL FEATURE.
73
+
74
+ * Added TextHelper#word_wrap(text, line_length = 80) #1449 [tuxie@dekadance.se]
75
+
76
+ * Added a fall-through action for form_remote_tag that'll be used in case Javascript is unavailable #1459 [Scott Barron]. Example:
77
+
78
+ form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") }
79
+
80
+ * Added :xhr => true/false option to verify so you can ensure that a request is coming from an Ajax call or not #1464 [Thomas Fuchs]
81
+
82
+ * Added tag_options as a third parameter to AssetHelper#auto_discovery_link_tag to control options like the title of the link #1430 [kevin.clark@gmail.com]
83
+
84
+ * Added option to pass in parameters to CaptureHelper#capture, so you can create more advanced view helper methods #1466 [duane.johnson@gmail.com]. Example:
85
+
86
+ <% show_calendar(:year => 2005, :month => 6) do |day, options| %>
87
+ <% options[:bgcolor] = '#dfd' if 10..15.include? day %>
88
+ [<%= day %>]
89
+ <% end %>
90
+
91
+ * Changed the default name of the input tag generated by FormTagHelper#submit_tag from "submit" to "commit" so it doesn't clash with form.submit() calls in Javascript #1271
92
+
93
+ * Fixed relative urls support for lighttpd #1048 [Nicholas Seckar/maznawak@nerim.net]
94
+
95
+ * Correct distance_of_time_in_words for integer arguments and make the second arg optional, treating the first arg as a duration in seconds. #1458 [madrobby <thomas@fesch.at>]
96
+
97
+ * Fixed query parser to deal gracefully with equal signs inside keys and values #1345 [gorou].
98
+ Example: /?sig=abcdef=:foobar=&x=y will pass now.
99
+
100
+ * Added Cuba to country list #1351 [todd]
101
+
102
+ * Fixed radio_button to work with numeric values #1352 [demetrius]
103
+
104
+ * Added :extension option to NumberHelper#number_to_phone #1361 [delynnb]
105
+
106
+ * Added button_to as a form-based solution to deal with harmful actions that should be hidden behind POSTs. This makes it just as easy as link_to to create a safe trigger for actions like destroy, although it's limited by being a block element, the fixed look, and a no-no inside other forms. #1371 [tom@moertel.com]
107
+
108
+ * Fixed image_tag so an exception is not thrown just because the image is missing and alt value can't be generated #1395 [Marcel]
109
+
110
+ * Added a third parameter to TextHelper#auto_link called href_options for specifying additional tag options on the links generated #1401 [tyler.kovacs@gmail.com]. Example: auto_link(text, :all, { :target => "_blank" }) to have all the generated links open in a new window.
111
+
112
+ * Fixed TextHelper#highlight to return the text, not nil, if the phrase is blank #1409 [patrick@lenz.sh]
113
+
114
+ * Fixed TagHelper such that :name and 'name' keys in the options doesn't result in two attributes #1455 [take_tk]
115
+
116
+ * Ensure that helpers are only available to the controllers where they are defined and their subclasses. #1394 [kdole@tamu.edu]
117
+
118
+ * render("foo/bar") works with a layout again
119
+
120
+ * Fixed double-singularization on scaffolded pagination call (Address would be turned into Addres) #1216, #1404 [nilsga]
121
+
122
+ * Removed the require hack used by functional testing to work around an earlier bug in rake.
123
+
124
+ * Allow distance_of_time_in_words to work with any value that responds to #to_time (like dates) #969
125
+
126
+ * Support :render option for :verify #1440 [TobiasLuetke]
127
+
128
+ * Updated vendor copy of html-scanner lib to 0.5.2, for bug fixes and optimizations. The :content option may be used as expected--to find a tag whose textual content is a particular value--in assert_tag, now.
129
+
130
+ * Changed test requests to come from 0.0.0.0 instead of 127.0.0.1 such that they don't trigger debugging screens on exceptions, but instead call rescue_action_in_public
131
+
132
+ * Modernize scaffolding to match the generator: use the new render method and change style from the warty @params["id"] to the sleek params[:id]. #1367
133
+
134
+ * Include :id in the action generated by the form helper method. Then, for example, the controller can do Model.find(params[:id]) for both edit and update actions. Updated scaffolding to take advantage. #1367
135
+
136
+ * Add assertions with friendly messages to TestCase#process to ensure that @controller, @request, and @response are set. #1367
137
+
138
+ * Arrays, hashes sent via multipart posts are converted to strings #1032 [dj@omelia.org, me@julik.nl]
139
+
140
+ * render(:layout => true) is a synonym for render(:layout => nil)
141
+
142
+ * Make sure the benchmarking render method always returns the output of the render.
143
+
144
+ * render(:action), render(:template) and render() are the only three calls that default to using a layout. All other render calls assume :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
145
+
146
+ * verify with :redirect_to won't redirect if a redirect or render has already been performed #1350
147
+
148
+ * render(:partial => true) is identical to the behavior of the deprecated render_partial()
149
+
150
+ * Fixed render(:partial => "...") to use an empty Hash for the local assigns #1365
151
+
152
+ * Fixed Caching::Fragments::FileStore.delete to not raise an exception if the delete fails.
153
+
154
+ * Deprecated all render_* methods in favor of consolidating all rendering behavior in Base#render(options). This enables more natural use of combining options, such as layouts. Examples:
155
+
156
+ +---------------------------------------------------------------+-------------------------------------------------------+
157
+ | BEFORE | AFTER |
158
+ +---------------------------------------------------------------+-------------------------------------------------------+
159
+ | render_with_layout "weblog/show", "200 OK", "layouts/dialog" | render :action => "show", :layout => "dialog" |
160
+ | render_without_layout "weblog/show" | render :action => "show", :layout => false |
161
+ | render_action "error", "404 Not Found" | render :action => "error", :status => "404 Not Found" |
162
+ | render_template "xml.div('stuff')", "200 OK", :rxml | render :inline => "xml.div('stuff')", :type => :rxml |
163
+ | render_text "hello world!" | render :text => "hello world!" |
164
+ | render_partial_collection "person", @people, nil, :a => 1 | render :partial => "person", :collection => @people, |
165
+ | | :locals => { :a => 1 } |
166
+ +---------------------------------------------------------------+-------------------------------------------------------+
167
+
168
+ * Deprecated redirect_to_path and redirect_to_url in favor of letting redirect_to do the right thing when passed either a path or url.
169
+
170
+ * Fixed use of an integer as return code for renders, so render_text "hello world", 404 now works #1327
171
+
172
+ * Fixed assert_redirect_to to work with redirect_to_path #869 [Nicholas Seckar]
173
+
174
+ * Fixed escaping of :method option in remote_form_tag #1218 [Rick Olson]
175
+
176
+ * Added Serbia and Montenegro to the country_select #1239 [todd@robotcoop.com]
177
+
178
+ * Fixed Request#remote_ip in testing #1251 [Jeremy Kemper]
179
+
180
+ * Fixed that compute_public_path should recognize external URLs, so image_tag("http://www.example.com/images/icon.gif") is not prefixed with the relative url path #1254 [victor-ronr-trac@carotena.net]
181
+
182
+ * Added support for descending year values in DateHelper#select_year, like select_year(Date.today, :start_year => 2005, :end_year => 1900), which would count down from 2005 to 1900 instead of the other way #1274 [nwoods@mail.com]
183
+
184
+ * Fixed that FormHelper#checkbox should return a checked checkbox if the value is the same as checked_value #1286 [Florian Weber]
185
+
186
+ * Fixed Form.disable in Prototype #1317 [Wintermute]
187
+
188
+ * Added accessors to logger, params, response, session, flash, and headers from the view, so you can write <% logger.info "stuff" %> instead of <% @logger.info "others" %> -- more consistent with the preferred way of accessing these attributes and collections from the controller
189
+
190
+ * Added support for POST data in form of YAML or XML, which is controller through the Content-Type header. Example request:
191
+
192
+ Content-Type: application/xml
193
+ <request><item><content>HelloWorld</content></item></request>
194
+
195
+ ...is the same as:
196
+
197
+ Content-Type: application/x-yaml
198
+ ---
199
+ item:
200
+ content: HelloWorld
201
+
202
+ ...is the same as:
203
+
204
+ item[content]=HelloWorld
205
+
206
+ Which in the end turns into { "item" => { "content" => "HelloWorld" } }. This makes it a lot easier to publish REST web services on top of your regular actions (as they won't care).
207
+
208
+ Example Curl call:
209
+
210
+ curl -H 'Content-Type: application/xml' -d '<request><item><content>KillMeMore</content></item></request>' http://www.example.com/service
211
+
212
+ You can query to find out whether a given request came through as one of these types with:
213
+ - request.post_format? (:url_encoded, :xml or :yaml)
214
+ - request.formatted_post? (for either xml or yaml)
215
+ - request.xml_post?
216
+ - request.yaml_post?
217
+
218
+ * Added bundling of XmlSimple by Maik Schmidt
219
+
220
+ * Fixed that render_partial_collection should always return a string (and not sometimes an array, despite <%= %> not caring)
221
+
222
+ * Added TextHelper#sanitize that can will remove any Javascript handlers, blocks, and forms from an input of HTML. This allows for use of HTML on public sites, but still be free of XSS issues. #1277 [Jamis Buck]
223
+
224
+ * Fixed the HTML scanner used by assert_tag where a infinite loop could be caused by a stray less-than sign in the input #1270 [Jamis Buck]
225
+
226
+ * Added functionality to assert_tag, so you can now do tests on the siblings of a node, to assert that some element comes before or after the element in question, or just to assert that some element exists as a sibling #1226 [Jamis Buck]
227
+
228
+ * Added better error handling for regexp caching expiration
229
+
230
+ * Fixed handling of requests coming from unknown HTTP methods not to kill the server
231
+
232
+ * Added that both AssetHelper#stylesheet_link_tag and AssetHelper#javascript_include_tag now accept an option hash as the last parameter, so you can do stuff like: stylesheet_link_tag "style", :media => "all"
233
+
234
+ * Added FormTagHelper#image_submit_tag for making submit buttons that uses images
235
+
236
+ * Added ActionController::Base.asset_host that will then be used by all the asset helpers. This enables you to easily offload static content like javascripts and images to a separate server tuned just for that.
237
+
238
+ * Fixed action/fragment caching using the filestore when a directory and a file wanted to to use the same name. Now there's a .cache prefix that sidesteps the conflict #1188 [imbcmdth@hotmail.com]
239
+
240
+ * Fixed missing id uniqueness in FormTag#radio_button #1207 [Jarkko]
241
+
242
+ * Fixed assert_redirected_to to work with :only_path => false #1204 [Alisdair McDiarmid]
243
+
244
+ * Fixed render_partial_collection to output an empty string instead of nil when handed an empty array #1202 [Ryan Carver]
245
+
246
+ * Improved the speed of regular expression expirations for caching by a factor of 10 #1221 [Jamis Buck]
247
+
248
+ * Removed dumping of template assigns on the rescue page as it would very easily include a ton of data making page loads take seconds (and the information was rarely helpful) #1222
249
+
250
+ * Added BenchmarkHelper that can measure the execution time of a block in a template and reports the result to the log. Example:
251
+
252
+ <% benchmark "Notes section" do %>
253
+ <%= expensive_notes_operation %>
254
+ <% end %>
255
+
256
+ Will add something like "Notes section (0.345234)" to the log.
257
+
258
+ * Added ActionController::Caching::Sweeper as an improved an easier to use sweeper. The new sweepers work on a single-step approach instead of two-steps like the old ones. Before
259
+
260
+ def after_save(record)
261
+ @list = record.is_a?(List) ? record : record.list
262
+ end
263
+
264
+ def filter(controller)
265
+ controller.expire_page(:controller => "lists", :action => %w( show public feed ), :id => @list.id)
266
+ controller.expire_action(:controller => "lists", :action => "all")
267
+ @list.shares.each { |share| controller.expire_page(:controller => "lists", :action => "show", :id => share.url_key) }
268
+ end
269
+
270
+ ..after:
271
+
272
+ def after_save(record)
273
+ list = record.is_a?(List) ? record : record.list
274
+ expire_page(:controller => "lists", :action => %w( show public feed ), :id => list.id)
275
+ expire_action(:controller => "lists", :action => "all")
276
+ list.shares.each { |share| expire_page(:controller => "lists", :action => "show", :id => share.url_key) }
277
+ end
278
+
279
+ The new sweepers can also observe on the actions themselves by implementing methods according to (before|after)_$controller_$action. Example of a callback that'll be called after PagesController#update_title has been performed:
280
+
281
+ def after_pages_update_title
282
+ expire_fragment(%r{pages/#{controller.assigns["page"].id}/.*})
283
+ end
284
+
285
+ Note that missing_method is delegated to the controller instance, which is assigned in a before filter. This means that you can call expire_fragment instead of @controller.expire_fragment.
286
+
287
+ * Added that Fragments#expire_fragment now accepts as a regular expression as the name thereby deprecating expire_matched_fragments
288
+
289
+ * Fixed that fragments shouldn't use the current host and the path as part of the key like pages does
290
+
291
+ * Added conditions to around_filters just like before_filter and after_filter
292
+
293
+
1
294
  *1.8.1* (20th April, 2005)
2
295
 
3
296
  * Added xml_http_request/xhr method for simulating XMLHttpRequest in functional tests #1151 [Sam Stephenson]. Example:
@@ -107,7 +400,7 @@
107
400
 
108
401
  * Added pagination for scaffolding (10 items per page) #964 [mortonda@dgrmm.net]
109
402
 
110
- * Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat]
403
+ * Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [Jeremy Kemper]
111
404
 
112
405
  * Fixed :overwrite_param so it doesn't delete but reject elements from @request.parameters #982 [raphinou@yahoo.com]
113
406
 
@@ -234,7 +527,7 @@
234
527
 
235
528
  * Removed the reliance on PATH_INFO as it was causing problems for caching and inhibited the new non-vhost support #822 [Nicholas Seckar]
236
529
 
237
- * Added assigns shortcut for @response.template.assigns to controller test cases [bitsweat]. Example:
530
+ * Added assigns shortcut for @response.template.assigns to controller test cases [Jeremy Kemper]. Example:
238
531
 
239
532
  Before:
240
533
 
@@ -273,7 +566,7 @@
273
566
 
274
567
  * Removed the default border on link_image_to (it broke xhtml strict) -- can be specified with :border => 0 #517 [?/caleb]
275
568
 
276
- * Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [bitsweat]
569
+ * Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [Jeremy Kemper]
277
570
 
278
571
  * Fixed that broken pipe errors (clients disconnecting in mid-request) could bring down a fcgi process
279
572
 
@@ -319,7 +612,7 @@
319
612
 
320
613
  * Added FormTagHelper that provides a number of methods for creating form tags that doesn't rely on conventions with an object assigned to the template like FormHelper does. With the FormTagHelper, you provide the names and values yourself.
321
614
 
322
- * Added Afghanistan, Iran, and Irak to the countries list used by FormOptions#country_select and FormOptions#country_options_for_select
615
+ * Added Afghanistan, Iran, and Iraq to the countries list used by FormOptions#country_select and FormOptions#country_options_for_select
323
616
 
324
617
  * Renamed link_to_image to link_image_to (since thats what it actually does) -- kept alias for the old method name
325
618
 
@@ -390,7 +683,7 @@
390
683
 
391
684
  * Added TestResponse#binary_content that'll return as a string the data sent through send_data/send_file for testing #500 [Alexey]
392
685
 
393
- * Added @request.env['RAW_POST_DATA'] for people who need access to the data before Ruby's CGI has parsed it #505 [bitsweat]
686
+ * Added @request.env['RAW_POST_DATA'] for people who need access to the data before Ruby's CGI has parsed it #505 [Jeremy Kemper]
394
687
 
395
688
  * Fixed that a default fragment store wan't being set to MemoryStore as intended.
396
689
 
@@ -450,7 +743,7 @@
450
743
 
451
744
  * Fixed that controller tests can now assert on the use of cookies #466 [Alexey]
452
745
 
453
- * Fixed that send_file would "remember" all the files sent by adding to the headers again and again #458 [bitsweat]
746
+ * Fixed that send_file would "remember" all the files sent by adding to the headers again and again #458 [Jeremy Kemper]
454
747
 
455
748
  * Fixed url rewriter confusion when the controller or action name was a substring of the controller_prefix or action_prefix
456
749
 
@@ -620,7 +913,7 @@
620
913
  and partials that make use of a counter can be called without problems from both render_collection_of_partials as well as
621
914
  render_partial #295 [marcel]
622
915
 
623
- * Fixed CgiRequest#out to fall back to #write if $stdout doesn't have #syswrite [bitsweat]
916
+ * Fixed CgiRequest#out to fall back to #write if $stdout doesn't have #syswrite [Jeremy Kemper]
624
917
 
625
918
  * Fixed all helpers so that they use XHTML compliant double quotes for values instead of single quotes [htonl/bitsweat]
626
919
 
@@ -670,7 +963,7 @@
670
963
 
671
964
  * Added options to tailor header tag, div id, and div class on ActiveRecordHelper#error_messages_for [josh]
672
965
 
673
- * Added graceful handling of non-alphanumeric names and misplaced brackets in input parameters [bitsweat]
966
+ * Added graceful handling of non-alphanumeric names and misplaced brackets in input parameters [Jeremy Kemper]
674
967
 
675
968
  * Added a new container for cookies that makes them more intuative to use. The old methods of cookie and @cookies have been deprecated.
676
969
 
@@ -694,7 +987,7 @@
694
987
 
695
988
  * Added Request#ssl? which is shorthand for @request.protocol == "https://"
696
989
 
697
- * Added the choice to call form_tag with no arguments (resulting in a form posting to current action) [bitsweat]
990
+ * Added the choice to call form_tag with no arguments (resulting in a form posting to current action) [Jeremy Kemper]
698
991
 
699
992
  * Upgraded to Builder 1.2.1
700
993
 
@@ -743,7 +1036,7 @@
743
1036
 
744
1037
  *0.9.5* (28)
745
1038
 
746
- * Added helper_method to designate that a given private or protected method you should available as a helper in the view. [bitsweat]
1039
+ * Added helper_method to designate that a given private or protected method you should available as a helper in the view. [Jeremy Kemper]
747
1040
 
748
1041
  * Fixed assert_rendered_file so it actually verifies if that was the rendered file [htonl]
749
1042
 
@@ -751,19 +1044,19 @@
751
1044
 
752
1045
  * Fixed that Russia was named twice in country_select [alexey]
753
1046
 
754
- * Fixed request_origin to use remote_ip instead of remote_addr [bitsweat]
1047
+ * Fixed request_origin to use remote_ip instead of remote_addr [Jeremy Kemper]
755
1048
 
756
1049
  * Fixed link_to breakage when nil was passed for html_options [alexey]
757
1050
 
758
1051
  * Fixed redirect_to on a virtual server setup with apache with a port other than the default where it would forget the port number [seanohalpin]
759
1052
 
760
- * Fixed that auto-loading webrick on Windows would cause file uploads to fail [bitsweat]
1053
+ * Fixed that auto-loading webrick on Windows would cause file uploads to fail [Jeremy Kemper]
761
1054
 
762
- * Fixed issues with sending files on WEBrick by setting the proper binmode [bitsweat]
1055
+ * Fixed issues with sending files on WEBrick by setting the proper binmode [Jeremy Kemper]
763
1056
 
764
- * Added send_data as an alternative to send_file when the stream is not read off the filesystem but from a database or generated live [bitsweat]
1057
+ * Added send_data as an alternative to send_file when the stream is not read off the filesystem but from a database or generated live [Jeremy Kemper]
765
1058
 
766
- * Added a new way to include helpers that doesn't require the include hack and can go without the explicit require. [bitsweat]
1059
+ * Added a new way to include helpers that doesn't require the include hack and can go without the explicit require. [Jeremy Kemper]
767
1060
 
768
1061
  Before:
769
1062
 
@@ -1432,4 +1725,4 @@
1432
1725
 
1433
1726
  *0.7.5*
1434
1727
 
1435
- * First public release
1728
+ * First public release
data/README CHANGED
@@ -43,7 +43,7 @@ A short rundown of the major features:
43
43
  @customer.attributes = @params["customer"]
44
44
  @customer.save ?
45
45
  redirect_to(:action => "display") :
46
- render("customer/edit")
46
+ render(:action => "edit")
47
47
  end
48
48
 
49
49
  private
@@ -32,6 +32,7 @@ rescue LoadError
32
32
  end
33
33
 
34
34
  require 'action_controller/base'
35
+ require 'action_controller/deprecated_renders_and_redirects'
35
36
  require 'action_controller/rescue'
36
37
  require 'action_controller/benchmarking'
37
38
  require 'action_controller/filters'
@@ -47,6 +48,8 @@ require 'action_controller/cgi_process'
47
48
  require 'action_controller/caching'
48
49
  require 'action_controller/components'
49
50
  require 'action_controller/verification'
51
+ require 'action_controller/streaming'
52
+ require 'action_controller/auto_complete'
50
53
 
51
54
  require 'action_view'
52
55
  ActionController::Base.template_class = ActionView::Base
@@ -66,4 +69,6 @@ ActionController::Base.class_eval do
66
69
  include ActionController::Caching
67
70
  include ActionController::Components
68
71
  include ActionController::Verification
72
+ include ActionController::Streaming
73
+ include ActionController::AutoComplete
69
74
  end
@@ -26,6 +26,25 @@ module Test #:nodoc:
26
26
  #
27
27
  # For redirects within the same controller, you can even call follow_redirect and the redirect will be follow triggering another
28
28
  # action call which can then be asserted against.
29
+ #
30
+ # == Manipulating the request collections
31
+ #
32
+ # The collections described above link to the response, so you can test if what the actions were expected to do happen. But
33
+ # some times you also want to manipulate these collections in the request coming in. This is really only relevant for sessions
34
+ # and cookies, though. For sessions, you just do:
35
+ #
36
+ # @request.session[:key] = "value"
37
+ #
38
+ # For cookies, you need to manually create the cookie, like this:
39
+ #
40
+ # @request.cookies["key"] = CGI::Cookie.new("key", "value")
41
+ #
42
+ # == Testing named routes
43
+ #
44
+ # If you're using named routes, they can be easily tested using the original named routes methods straight in the test case.
45
+ # Example:
46
+ #
47
+ # assert_redirected_to page_url(:title => 'foo')
29
48
  module Assertions
30
49
  # Asserts that the response is one of the following types:
31
50
  #
@@ -49,15 +68,32 @@ module Test #:nodoc:
49
68
  # such at assert_redirected_to(:controller => "weblog") will also match the redirection of
50
69
  # redirect_to(:controller => "weblog", :action => "show") and so on.
51
70
  def assert_redirected_to(options = {}, message=nil)
52
- assert_redirect(message)
71
+ assert_response(:redirect, message)
53
72
 
54
- msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)", @response.redirected_to)
55
- assert_block(msg) do
56
- if options.is_a?(Symbol)
57
- @response.redirected_to == options
58
- else
59
- options.keys.all? do |k|
60
- options[k] == (@response.redirected_to[k].respond_to?(:to_param) ? @response.redirected_to[k].to_param : @response.redirected_to[k] if @response.redirected_to[k])
73
+ if options.is_a?(String)
74
+ msg = build_message(message, "expected a redirect to <?>, found one to <?>", options, @response.redirect_url)
75
+ url_regexp = %r{^(\w+://.*?(/|$|\?))(.*)$}
76
+ eurl, epath, url, path = [options, @response.redirect_url].collect do |url|
77
+ u, p = (url_regexp =~ url) ? [$1, $3] : [nil, url]
78
+ [u, (p[0..0] == '/') ? p : '/' + p]
79
+ end.flatten
80
+
81
+ if eurl && url then assert_equal(eurl, url, msg)
82
+ else assert_equal(epath, path, msg)
83
+ end
84
+ else
85
+ msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)",
86
+ @response.redirected_to || @response.redirect_url)
87
+
88
+ assert_block(msg) do
89
+ if options.is_a?(Symbol)
90
+ @response.redirected_to == options
91
+ else
92
+ options.keys.all? do |k|
93
+ if k == :controller then options[k] == ActionController::Routing.controller_relative_to(@response.redirected_to[k], @controller.class.controller_path)
94
+ else options[k] == (@response.redirected_to[k].respond_to?(:to_param) ? @response.redirected_to[k].to_param : @response.redirected_to[k] unless @response.redirected_to[k].nil?)
95
+ end
96
+ end
61
97
  end
62
98
  end
63
99
  end
@@ -69,7 +105,7 @@ module Test #:nodoc:
69
105
  msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
70
106
  assert_block(msg) do
71
107
  if expected.nil?
72
- @response.rendered_with_file?
108
+ !@response.rendered_with_file?
73
109
  else
74
110
  expected == rendered
75
111
  end
@@ -78,6 +114,7 @@ module Test #:nodoc:
78
114
 
79
115
  # Asserts that the routing of the given path is handled correctly and that the parsed options match.
80
116
  def assert_recognizes(expected_options, path, extras={}, message=nil)
117
+ path = "/#{path}" unless path[0..0] == '/'
81
118
  # Load routes.rb if it hasn't been loaded.
82
119
  ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
83
120
 
@@ -89,6 +126,7 @@ module Test #:nodoc:
89
126
  expected_options = expected_options.clone
90
127
  extras.each_key { |key| expected_options.delete key } unless extras.nil?
91
128
 
129
+ expected_options.stringify_keys!
92
130
  msg = build_message(message, "The recognized options <?> did not match <?>",
93
131
  request.path_parameters, expected_options)
94
132
  assert_block(msg) { request.path_parameters == expected_options }
@@ -96,6 +134,7 @@ module Test #:nodoc:
96
134
 
97
135
  # Asserts that the provided options can be used to generate the provided path.
98
136
  def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
137
+ expected_path = "/#{expected_path}" unless expected_path[0] == ?/
99
138
  # Load routes.rb if it hasn't been loaded.
100
139
  ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
101
140
 
@@ -105,7 +144,6 @@ module Test #:nodoc:
105
144
  request.path_parameters[:controller] ||= options[:controller]
106
145
 
107
146
  generated_path, found_extras = ActionController::Routing::Routes.generate(options, request)
108
- generated_path = generated_path.join('/')
109
147
  msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
110
148
  assert_block(msg) { found_extras == extras }
111
149
 
@@ -136,6 +174,12 @@ module Test #:nodoc:
136
174
  # meet the criteria described by the hash.
137
175
  # * <tt>:descendant</tt>: a hash. At least one of the node's descendants
138
176
  # must meet the criteria described by the hash.
177
+ # * <tt>:sibling</tt>: a hash. At least one of the node's siblings must
178
+ # meet the criteria described by the hash.
179
+ # * <tt>:after</tt>: a hash. The node must be after any sibling meeting
180
+ # the criteria described by the hash, and at least one sibling must match.
181
+ # * <tt>:before</tt>: a hash. The node must be before any sibling meeting
182
+ # the criteria described by the hash, and at least one sibling must match.
139
183
  # * <tt>:children</tt>: a hash, for counting children of a node. Accepts
140
184
  # the keys:
141
185
  # * <tt>:count</tt>: either a number or a range which must equal (or
@@ -147,8 +191,9 @@ module Test #:nodoc:
147
191
  # * <tt>:only</tt>: another hash consisting of the keys to use
148
192
  # to match on the children, and only matching children will be
149
193
  # counted.
150
- # * <tt>:content</tt>: (text nodes only). The content of the node must
151
- # match the given value.
194
+ # * <tt>:content</tt>: the textual content of the node must match the
195
+ # given value. This will not match HTML tags in the body of a
196
+ # tag--only text.
152
197
  #
153
198
  # Conditions are matched using the following algorithm:
154
199
  #