actionpack 2.0.1 → 2.0.2

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

Potentially problematic release.


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

Files changed (40) hide show
  1. data/CHANGELOG +59 -26
  2. data/Rakefile +1 -1
  3. data/lib/action_controller/base.rb +6 -16
  4. data/lib/action_controller/benchmarking.rb +5 -4
  5. data/lib/action_controller/caching.rb +2 -2
  6. data/lib/action_controller/cgi_ext/cookie.rb +1 -5
  7. data/lib/action_controller/cookies.rb +3 -3
  8. data/lib/action_controller/dispatcher.rb +1 -1
  9. data/lib/action_controller/helpers.rb +2 -3
  10. data/lib/action_controller/integration.rb +29 -14
  11. data/lib/action_controller/layout.rb +2 -1
  12. data/lib/action_controller/request.rb +1 -1
  13. data/lib/action_controller/request_forgery_protection.rb +7 -1
  14. data/lib/action_controller/rescue.rb +1 -1
  15. data/lib/action_controller/routing.rb +12 -9
  16. data/lib/action_controller/session/cookie_store.rb +3 -0
  17. data/lib/action_pack/version.rb +1 -1
  18. data/lib/action_view.rb +6 -0
  19. data/lib/action_view/base.rb +83 -140
  20. data/lib/action_view/helpers/asset_tag_helper.rb +68 -46
  21. data/lib/action_view/helpers/text_helper.rb +2 -2
  22. data/lib/action_view/template_handler.rb +17 -0
  23. data/lib/action_view/template_handlers/builder.rb +19 -0
  24. data/lib/action_view/template_handlers/erb.rb +21 -0
  25. data/lib/action_view/template_handlers/rjs.rb +14 -0
  26. data/test/action_view_test.rb +18 -0
  27. data/test/controller/cgi_test.rb +4 -4
  28. data/test/controller/cookie_test.rb +1 -1
  29. data/test/controller/filters_test.rb +1 -0
  30. data/test/controller/helper_test.rb +8 -6
  31. data/test/controller/integration_test.rb +41 -11
  32. data/test/controller/new_render_test.rb +2 -2
  33. data/test/controller/render_test.rb +31 -10
  34. data/test/controller/request_test.rb +2 -1
  35. data/test/controller/routing_test.rb +9 -3
  36. data/test/fixtures/test/{hello_world.builder → hello_world_from_rxml.builder} +0 -0
  37. data/test/template/asset_tag_helper_test.rb +45 -12
  38. data/test/template/compiled_templates_test.rb +14 -12
  39. data/test/template/erb_util_test.rb +56 -0
  40. metadata +56 -43
data/CHANGELOG CHANGED
@@ -1,3 +1,36 @@
1
+ *2.0.2* (December 16th, 2007)
2
+
3
+ * Added delete_via_redirect and put_via_redirect to integration testing #10497 [philodespotos]
4
+
5
+ * Allow headers['Accept'] to be set by hand when calling xml_http_request #10461 [BMorearty]
6
+
7
+ * Added OPTIONS to list of default accepted HTTP methods #10449 [holoway]
8
+
9
+ * Added option to pass proc to ActionController::Base.asset_host for maximum configurability #10521 [chuyeow]. Example:
10
+
11
+ ActionController::Base.asset_host = Proc.new { |source|
12
+ if source.starts_with?('/images')
13
+ "http://images.example.com"
14
+ else
15
+ "http://assets.example.com"
16
+ end
17
+ }
18
+
19
+ * Fixed that ActionView#file_exists? would be incorrect if @first_render is set #10569 [dbussink]
20
+
21
+ * Added that Array#to_param calls to_param on all it's elements #10473 [brandon]
22
+
23
+ * Ensure asset cache directories are automatically created. #10337 [Josh Peek, Cheah Chu Yeow]
24
+
25
+ * render :xml and :json preserve custom content types. #10388 [jmettraux, Cheah Chu Yeow]
26
+
27
+ * Refactor Action View template handlers. #10437, #10455 [Josh Peek]
28
+
29
+ * Fix DoubleRenderError message and leave out mention of returning false from filters. Closes #10380 [Frederick Cheung]
30
+
31
+ * Clean up some cruft around ActionController::Base#head. Closes #10417 [ssoroka]
32
+
33
+
1
34
  *2.0.1* (December 7th, 2007)
2
35
 
3
36
  * Fixed send_file/binary_content for testing #8044 [tolsen]
@@ -14,7 +47,7 @@
14
47
 
15
48
  * Fixed that verification violations with no specified action didn't halt the chain (now they do with a 400 Bad Request) [DHH]
16
49
 
17
- * Raise UnknownHttpMethod exception for unknown HTTP methods. Closes #10303 [tarmo]
50
+ * Raise UnknownHttpMethod exception for unknown HTTP methods. Closes #10303 [Tarmo Tänav]
18
51
 
19
52
  * Update to Prototype -r8232. [sam]
20
53
 
@@ -106,7 +139,7 @@
106
139
 
107
140
  * Make sure resource routes don't clash with internal helpers like javascript_path, image_path etc. #9928 [gbuesing]
108
141
 
109
- * caches_page uses a single after_filter instead of one per action. #9891 [lifofifo]
142
+ * caches_page uses a single after_filter instead of one per action. #9891 [Pratik Naik]
110
143
 
111
144
  * Update Prototype to 1.6.0_rc1 and script.aculo.us to 1.8.0 preview 0. [sam, madrobby]
112
145
 
@@ -122,11 +155,11 @@
122
155
 
123
156
  * Extracted sanitization methods from TextHelper to SanitizeHelper [DHH]
124
157
 
125
- * rescue_from accepts :with => lambda { |exception| ... } or a normal block. #9827 [lifofifo]
158
+ * rescue_from accepts :with => lambda { |exception| ... } or a normal block. #9827 [Pratik Naik]
126
159
 
127
160
  * Add :status to redirect_to allowing users to choose their own response code without manually setting headers. #8297 [codahale, chasgrundy]
128
161
 
129
- * Add link_to :back which uses your referrer with a fallback to a javascript link. #7366 [eventualbuddha, tarmo]
162
+ * Add link_to :back which uses your referrer with a fallback to a javascript link. #7366 [eventualbuddha, Tarmo Tänav]
130
163
 
131
164
  * error_messages_for and friends also work with local variables. #9699 [Frederick Cheung]
132
165
 
@@ -149,7 +182,7 @@
149
182
 
150
183
  * Better error messages if you leave out the :secret option for request forgery protection. Closes #9670 [rick]
151
184
 
152
- * Allow ability to disable request forgery protection, disable it in test mode by default. Closes #9693 [lifofifo]
185
+ * Allow ability to disable request forgery protection, disable it in test mode by default. Closes #9693 [Pratik Naik]
153
186
 
154
187
  * Avoid calling is_missing on LoadErrors. Closes #7460. [ntalbott]
155
188
 
@@ -161,13 +194,13 @@
161
194
 
162
195
  * Optimized named routes respect AbstractRequest.relative_url_root. #9612 [danielmorrison, Jeremy Kemper]
163
196
 
164
- * Introduce ActionController::Base.rescue_from to declare exception-handling methods. Cleaner style than the case-heavy rescue_action_in_public. #9449 [norbert]
197
+ * Introduce ActionController::Base.rescue_from to declare exception-handling methods. Cleaner style than the case-heavy rescue_action_in_public. #9449 [Norbert Crombach]
165
198
 
166
199
  * Rename some RequestForgeryProtection methods. The class method is now #protect_from_forgery, and the default parameter is now 'authenticity_token'. [Rick]
167
200
 
168
201
  * Merge csrf_killer plugin into rails. Adds RequestForgeryProtection model that verifies session-specific _tokens for non-GET requests. [Rick]
169
202
 
170
- * Secure #sanitize, #strip_tags, and #strip_links helpers against xss attacks. Closes #8877. [Rick, lifofifo, Jacques Distler]
203
+ * Secure #sanitize, #strip_tags, and #strip_links helpers against xss attacks. Closes #8877. [Rick, Pratik Naik, Jacques Distler]
171
204
 
172
205
  This merges and renames the popular white_list helper (along with some css sanitizing from Jacques Distler version of the same plugin).
173
206
  Also applied updated versions of #strip_tags and #strip_links from #8877.
@@ -186,7 +219,7 @@
186
219
 
187
220
  * Prevent errors when generating routes for uncountable resources, (i.e. sheep where plural == singluar). map.resources :sheep now creates sheep_index_url for the collection and sheep_url for the specific item. [Koz]
188
221
 
189
- * Added support for HTTP Only cookies (works in IE6+ and FF 2.0.5+) as an improvement for XSS attacks #8895 [lifo/Spakman]
222
+ * Added support for HTTP Only cookies (works in IE6+ and FF 2.0.5+) as an improvement for XSS attacks #8895 [Pratik Naik, Spakman]
190
223
 
191
224
  * Don't warn when a path segment precedes a required segment. Closes #9615. [Nicholas Seckar]
192
225
 
@@ -217,15 +250,15 @@
217
250
 
218
251
  * Added that render :json will automatically call .to_json unless it's being passed a string [DHH].
219
252
 
220
- * Autolink behaves well with emails embedded in URLs. #7313 [Jeremy McAnally, tarmo]
253
+ * Autolink behaves well with emails embedded in URLs. #7313 [Jeremy McAnally, Tarmo Tänav]
221
254
 
222
- * Fixed that default layouts did not take the format into account #9564 [lifofifo]
255
+ * Fixed that default layouts did not take the format into account #9564 [Pratik Naik]
223
256
 
224
257
  * Fixed optimized route segment escaping. #9562 [wildchild, Jeremy Kemper]
225
258
 
226
259
  * Added block acceptance to JavaScriptHelper#javascript_tag. #7527 [Bob Silva, Tarmo Tänav, rmm5t]
227
260
 
228
- * root_path returns '/' not ''. #9563 [lifofifo]
261
+ * root_path returns '/' not ''. #9563 [Pratik Naik]
229
262
 
230
263
  * Fixed that setting request.format should also affect respond_to blocks [DHH]
231
264
 
@@ -233,9 +266,9 @@
233
266
 
234
267
  * Fixed that resource namespaces wouldn't stick to all nested resources #9399 [pixeltrix]
235
268
 
236
- * Moved ActionController::Macros::AutoComplete into the auto_complete plugin on the official Rails svn #9512 [lifofifo]
269
+ * Moved ActionController::Macros::AutoComplete into the auto_complete plugin on the official Rails svn. #9512 [Pratik Naik]
237
270
 
238
- * Moved ActionController::Macros::InPlaceEditing into the in_place_editor plugin on the official Rails svn #9513 [lifofifo]
271
+ * Moved ActionController::Macros::InPlaceEditing into the in_place_editor plugin on the official Rails svn. #9513 [Pratik Naik]
239
272
 
240
273
  * Removed deprecated form of calling xml_http_request/xhr without the first argument being the http verb [DHH]
241
274
 
@@ -265,7 +298,7 @@
265
298
 
266
299
  * Allow additional parameters to be passed to named route helpers when using positional arguments. Closes #8930 [ian.w.white@gmail.com]
267
300
 
268
- * Make render :partial work with a :collection of Hashes, previously this wasn't possible due to backwards compatibility restrictions. [lifofifo]
301
+ * Make render :partial work with a :collection of Hashes, previously this wasn't possible due to backwards compatibility restrictions. [Pratik Naik]
269
302
 
270
303
  * request.host works with IPv6 addresses. #9458 [yuya]
271
304
 
@@ -295,9 +328,9 @@
295
328
  this behaviour are advised to put the code in question after a yield statement in an around filter.
296
329
 
297
330
 
298
- * Allow you to delete cookies with options. Closes #3685 [josh, Chris Wanstrath]
331
+ * Allow you to delete cookies with options. Closes #3685 [Josh Peek, Chris Wanstrath]
299
332
 
300
- * Allow you to render views with periods in the name. Closes #8076 [norbert]
333
+ * Allow you to render views with periods in the name. Closes #8076 [Norbert Crombach]
301
334
 
302
335
  render :partial => 'show.html.erb'
303
336
 
@@ -311,13 +344,13 @@
311
344
 
312
345
  * Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility. [Jeremy Kemper]
313
346
 
314
- * Fixed that link_to with an href of # when using :method will not allow for click-through without JavaScript #7037 [stevenbristol/josh]
347
+ * Fixed that link_to with an href of # when using :method will not allow for click-through without JavaScript #7037 [Steven Bristol, Josh Peek]
315
348
 
316
- * Fixed that radio_button_tag should generate unique ids #3353 [BobSilva/rebecca/josh]
349
+ * Fixed that radio_button_tag should generate unique ids #3353 [Bob Silva, Rebecca, Josh Peek]
317
350
 
318
351
  * Fixed that HTTP authentication should work if the header is called REDIRECT_X_HTTP_AUTHORIZATION as well #6754 [mislaw]
319
352
 
320
- * Don't mistakenly interpret the request uri as the query string. #8731 [lifofifo, Jeremy Kemper]
353
+ * Don't mistakenly interpret the request uri as the query string. #8731 [Pratik Naik, Jeremy Kemper]
321
354
 
322
355
  * Make ActionView#view_paths an attr_accessor for real this time. Also, don't perform an unnecessary #compact on the @view_paths array in #initialize. Closes #8582 [dasil003, julik, rick]
323
356
 
@@ -345,7 +378,7 @@
345
378
 
346
379
  * Routing: map.resource :logo routes to LogosController so the controller may be reused for multiple nestings or namespaces. [Jeremy Kemper]
347
380
 
348
- * render :partial recognizes Active Record associations as Arrays. #8538 [kamal]
381
+ * render :partial recognizes Active Record associations as Arrays. #8538 [Kamal Fariz Mahyuddin]
349
382
 
350
383
  * Routing: drop semicolon and comma as route separators. [Jeremy Kemper]
351
384
 
@@ -365,7 +398,7 @@
365
398
 
366
399
  * Wordsmith resources documentation. #8484 [marclove]
367
400
 
368
- * Fix syntax error in code example for routing documentation. #8377. [norbert]
401
+ * Fix syntax error in code example for routing documentation. #8377. [Norbert Crombach]
369
402
 
370
403
  * Routing: respond with 405 Method Not Allowed status when the route path matches but the HTTP method does not. #6953 [Josh Peek, defeated, Dan Kubb, Coda Hale]
371
404
 
@@ -377,7 +410,7 @@
377
410
 
378
411
  * auto_complete_field takes a :method option so you can GET or POST. #8120 [zapnap]
379
412
 
380
- * Added option to suppress :size when using :maxlength for FormTagHelper#text_field #3112 [rails@tpope.info]
413
+ * Added option to suppress :size when using :maxlength for FormTagHelper#text_field #3112 [Tim Pope]
381
414
 
382
415
  * catch possible WSOD when trying to render a missing partial. Closes #8454 [Catfish]
383
416
 
@@ -481,7 +514,7 @@
481
514
 
482
515
  * Enhance documentation and add examples for url_for. [jeremymcanally]
483
516
 
484
- * Fix documentation typo in routes. [norbert, pam]
517
+ * Fix documentation typo in routes. [Norbert Crombach, pam]
485
518
 
486
519
  * Sweep flash when filter chain is halted. [Caio Chassot <lists@v2studio.com>]
487
520
 
@@ -567,7 +600,7 @@
567
600
 
568
601
  * Ensure that render_text only adds string content to the body of the response [DHH]
569
602
 
570
- * Return the string representation from an Xml Builder when rendering a partial. Closes #5044 [tpope]
603
+ * Return the string representation from an Xml Builder when rendering a partial. Closes #5044 [Tim Pope]
571
604
 
572
605
  * Fixed that parameters from XML should also be presented in a hash with indifferent access [DHH]
573
606
 
@@ -928,7 +961,7 @@ superclass' view_paths. [Rick]
928
961
 
929
962
  * Deprecate JavaScriptHelper#update_element_function, which is superseeded by RJS [Thomas Fuchs]
930
963
 
931
- * pluralize helper interprets nil as zero. #6474 [pope]
964
+ * pluralize helper interprets nil as zero. #6474 [Tim Pope]
932
965
 
933
966
  * Fix invalid test fixture exposed by stricter Ruby 1.8.5 multipart parsing. #6524 [Bob Silva]
934
967
 
@@ -3806,7 +3839,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car
3806
3839
 
3807
3840
  * Fixed that cached template loading would still check the file system to see if the file existed #258 [Andreas Schwarz]
3808
3841
 
3809
- * Added options to tailor header tag, div id, and div class on ActiveRecordHelper#error_messages_for [josh]
3842
+ * Added options to tailor header tag, div id, and div class on ActiveRecordHelper#error_messages_for [Josh Peek]
3810
3843
 
3811
3844
  * Added graceful handling of non-alphanumeric names and misplaced brackets in input parameters [Jeremy Kemper]
3812
3845
 
data/Rakefile CHANGED
@@ -76,7 +76,7 @@ spec = Gem::Specification.new do |s|
76
76
  s.has_rdoc = true
77
77
  s.requirements << 'none'
78
78
 
79
- s.add_dependency('activesupport', '= 2.0.1' + PKG_BUILD)
79
+ s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD)
80
80
 
81
81
  s.require_path = 'lib'
82
82
  s.autorequire = 'action_controller'
@@ -70,7 +70,7 @@ module ActionController #:nodoc:
70
70
  end
71
71
 
72
72
  class DoubleRenderError < ActionControllerError #:nodoc:
73
- DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so \"render(...) and return false\"."
73
+ DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
74
74
 
75
75
  def initialize(message = nil)
76
76
  super(message || DEFAULT_MESSAGE)
@@ -862,7 +862,7 @@ module ActionController #:nodoc:
862
862
 
863
863
  elsif inline = options[:inline]
864
864
  add_variables_to_assigns
865
- render_for_text(@template.render_template(options[:type] || :erb, inline, nil, options[:locals] || {}), options[:status])
865
+ render_for_text(@template.render_template(options[:type], inline, nil, options[:locals] || {}), options[:status])
866
866
 
867
867
  elsif action_name = options[:action]
868
868
  template = default_template_name(action_name.to_s)
@@ -873,13 +873,13 @@ module ActionController #:nodoc:
873
873
  end
874
874
 
875
875
  elsif xml = options[:xml]
876
- response.content_type = Mime::XML
876
+ response.content_type ||= Mime::XML
877
877
  render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status])
878
878
 
879
879
  elsif json = options[:json]
880
880
  json = json.to_json unless json.is_a?(String)
881
881
  json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
882
- response.content_type = Mime::JSON
882
+ response.content_type ||= Mime::JSON
883
883
  render_for_text(json, options[:status])
884
884
 
885
885
  elsif partial = options[:partial]
@@ -943,19 +943,9 @@ module ActionController #:nodoc:
943
943
  raise ArgumentError, "too many arguments to head"
944
944
  elsif args.empty?
945
945
  raise ArgumentError, "too few arguments to head"
946
- elsif args.length == 2
947
- status = args.shift
948
- options = args.shift
949
- elsif args.first.is_a?(Hash)
950
- options = args.first
951
- else
952
- status = args.first
953
- options = {}
954
946
  end
955
-
956
- raise ArgumentError, "head requires an options hash" if !options.is_a?(Hash)
957
-
958
- status = interpret_status(status || options.delete(:status) || :ok)
947
+ options = args.extract_options!
948
+ status = interpret_status(args.shift || options.delete(:status) || :ok)
959
949
 
960
950
  options.each do |key, value|
961
951
  headers[key.to_s.dasherize.split(/-/).map { |v| v.capitalize }.join("-")] = value.to_s
@@ -79,15 +79,16 @@ module ActionController #:nodoc:
79
79
  end
80
80
 
81
81
  def rendering_runtime(runtime)
82
- " | Rendering: #{sprintf("%.5f", @rendering_runtime)} (#{sprintf("%d", (@rendering_runtime * 100) / runtime)}%)"
82
+ percentage = @rendering_runtime * 100 / runtime
83
+ " | Rendering: %.5f (%d%%)" % [@rendering_runtime, percentage.to_i]
83
84
  end
84
85
 
85
86
  def active_record_runtime(runtime)
86
87
  db_runtime = ActiveRecord::Base.connection.reset_runtime
87
88
  db_runtime += @db_rt_before_render if @db_rt_before_render
88
89
  db_runtime += @db_rt_after_render if @db_rt_after_render
89
- db_percentage = (db_runtime * 100) / runtime
90
- " | DB: #{sprintf("%.5f", db_runtime)} (#{sprintf("%d", db_percentage)}%)"
90
+ db_percentage = db_runtime * 100 / runtime
91
+ " | DB: %.5f (%d%%)" % [db_runtime, db_percentage.to_i]
91
92
  end
92
93
  end
93
- end
94
+ end
@@ -81,7 +81,7 @@ module ActionController #:nodoc:
81
81
  return unless perform_caching
82
82
 
83
83
  benchmark "Expired page: #{page_cache_file(path)}" do
84
- File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path))
84
+ File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path))
85
85
  end
86
86
  end
87
87
 
@@ -552,7 +552,7 @@ module ActionController #:nodoc:
552
552
  end
553
553
 
554
554
  def ensure_cache_path(path)
555
- FileUtils.makedirs(path) unless File.exists?(path)
555
+ FileUtils.makedirs(path) unless File.exist?(path)
556
556
  end
557
557
 
558
558
  def search_dir(dir, &callback)
@@ -56,10 +56,6 @@ class CGI #:nodoc:
56
56
  super(@value)
57
57
  end
58
58
 
59
- def __setobj__(obj)
60
- @_dc_obj = obj
61
- end
62
-
63
59
  # Set whether the Cookie is a secure cookie or not.
64
60
  def secure=(val)
65
61
  @secure = val == true
@@ -93,7 +89,7 @@ class CGI #:nodoc:
93
89
  cookies = Hash.new([])
94
90
 
95
91
  if raw_cookie
96
- raw_cookie.split(/; ?/).each do |pairs|
92
+ raw_cookie.split(/[;,]\s?/).each do |pairs|
97
93
  name, values = pairs.split('=',2)
98
94
  next unless name and values
99
95
  name = CGI::unescape(name)
@@ -50,8 +50,8 @@ module ActionController #:nodoc:
50
50
  def [](name)
51
51
  cookie = @cookies[name.to_s]
52
52
  if cookie && cookie.respond_to?(:value)
53
- cookie.size > 1 ? cookie.value : cookie.value.to_s
54
- end
53
+ cookie.size > 1 ? cookie.value : cookie.value[0]
54
+ end
55
55
  end
56
56
 
57
57
  def []=(name, options)
@@ -81,4 +81,4 @@ module ActionController #:nodoc:
81
81
  @controller.response.headers["cookie"] << cookie
82
82
  end
83
83
  end
84
- end
84
+ end
@@ -4,7 +4,7 @@ module ActionController
4
4
  class Dispatcher
5
5
  class << self
6
6
  # Backward-compatible class method takes CGI-specific args. Deprecated
7
- # in favor of Dispatcher.new(output, request, response).dispatch!
7
+ # in favor of Dispatcher.new(output, request, response).dispatch.
8
8
  def dispatch(cgi = nil, session_options = CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout)
9
9
  new(output).dispatch_cgi(cgi, session_options)
10
10
  end
@@ -1,3 +1,4 @@
1
+ # FIXME: helper { ... } is broken on Ruby 1.9
1
2
  module ActionController #:nodoc:
2
3
  module Helpers #:nodoc:
3
4
  HELPERS_DIR = (defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/app/helpers" : "app/helpers")
@@ -120,7 +121,7 @@ module ActionController #:nodoc:
120
121
  begin
121
122
  require_dependency(file_name)
122
123
  rescue LoadError => load_error
123
- requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1]
124
+ requiree = / -- (.*?)(\.rb)?$/.match(load_error.message).to_a[1]
124
125
  if requiree == file_name
125
126
  msg = "Missing helper file helpers/#{file_name}.rb"
126
127
  raise LoadError.new(msg).copy_blame!(load_error)
@@ -177,10 +178,8 @@ module ActionController #:nodoc:
177
178
  end
178
179
  rescue MissingSourceFile => e
179
180
  raise unless e.is_missing? module_path
180
- logger.debug("#{name}: missing default helper path #{module_path}") if logger
181
181
  rescue NameError => e
182
182
  raise unless e.missing_name? module_name
183
- logger.debug("#{name}: missing default helper module #{module_name}") if logger
184
183
  end
185
184
 
186
185
  def inherited_with_helper(child)
@@ -121,23 +121,38 @@ module ActionController
121
121
  status
122
122
  end
123
123
 
124
- # Performs a GET request, following any subsequent redirect. Note that
125
- # the redirects are followed until the response is not a redirect--this
126
- # means you may run into an infinite loop if your redirect loops back to
127
- # itself. Headers are treated in the same way as #get.
128
- def get_via_redirect(path, args={}, headers = {})
129
- get path, args, headers
124
+ # Performs a request using the specified method, following any subsequent
125
+ # redirect. Note that the redirects are followed until the response is
126
+ # not a redirect--this means you may run into an infinite loop if your
127
+ # redirect loops back to itself.
128
+ def request_via_redirect(http_method, path, parameters = nil, headers = nil)
129
+ send(http_method, path, parameters, headers)
130
130
  follow_redirect! while redirect?
131
131
  status
132
132
  end
133
133
 
134
- # Performs a POST request, following any subsequent redirect. This is
135
- # vulnerable to infinite loops, the same as #get_via_redirect. Headers are
136
- # treated in the same way as #get.
137
- def post_via_redirect(path, args={}, headers = {})
138
- post path, args, headers
139
- follow_redirect! while redirect?
140
- status
134
+ # Performs a GET request, following any subsequent redirect.
135
+ # See #request_via_redirect() for more information.
136
+ def get_via_redirect(path, parameters = nil, headers = nil)
137
+ request_via_redirect(:get, path, parameters, headers)
138
+ end
139
+
140
+ # Performs a POST request, following any subsequent redirect.
141
+ # See #request_via_redirect() for more information.
142
+ def post_via_redirect(path, parameters = nil, headers = nil)
143
+ request_via_redirect(:post, path, parameters, headers)
144
+ end
145
+
146
+ # Performs a PUT request, following any subsequent redirect.
147
+ # See #request_via_redirect() for more information.
148
+ def put_via_redirect(path, parameters = nil, headers = nil)
149
+ request_via_redirect(:put, path, parameters, headers)
150
+ end
151
+
152
+ # Performs a DELETE request, following any subsequent redirect.
153
+ # See #request_via_redirect() for more information.
154
+ def delete_via_redirect(path, parameters = nil, headers = nil)
155
+ request_via_redirect(:delete, path, parameters, headers)
141
156
  end
142
157
 
143
158
  # Returns +true+ if the last response was a redirect.
@@ -187,7 +202,7 @@ module ActionController
187
202
  def xml_http_request(request_method, path, parameters = nil, headers = nil)
188
203
  headers ||= {}
189
204
  headers['X-Requested-With'] = 'XMLHttpRequest'
190
- headers['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*'
205
+ headers['Accept'] ||= 'text/javascript, text/html, application/xml, text/xml, */*'
191
206
 
192
207
  process(request_method, path, parameters, headers)
193
208
  end