actionpack 1.12.5 → 1.13.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 (179) hide show
  1. data/CHANGELOG +517 -15
  2. data/MIT-LICENSE +1 -1
  3. data/README +18 -20
  4. data/Rakefile +7 -4
  5. data/examples/address_book_controller.rb +3 -3
  6. data/examples/blog_controller.cgi +3 -3
  7. data/examples/debate_controller.cgi +5 -5
  8. data/lib/action_controller.rb +2 -2
  9. data/lib/action_controller/assertions.rb +73 -311
  10. data/lib/action_controller/{deprecated_assertions.rb → assertions/deprecated_assertions.rb} +32 -8
  11. data/lib/action_controller/assertions/dom_assertions.rb +25 -0
  12. data/lib/action_controller/assertions/model_assertions.rb +12 -0
  13. data/lib/action_controller/assertions/response_assertions.rb +140 -0
  14. data/lib/action_controller/assertions/routing_assertions.rb +82 -0
  15. data/lib/action_controller/assertions/selector_assertions.rb +571 -0
  16. data/lib/action_controller/assertions/tag_assertions.rb +117 -0
  17. data/lib/action_controller/base.rb +334 -163
  18. data/lib/action_controller/benchmarking.rb +3 -6
  19. data/lib/action_controller/caching.rb +83 -22
  20. data/lib/action_controller/cgi_ext/cgi_ext.rb +0 -7
  21. data/lib/action_controller/cgi_ext/cgi_methods.rb +167 -173
  22. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +43 -22
  23. data/lib/action_controller/cgi_process.rb +50 -27
  24. data/lib/action_controller/components.rb +21 -25
  25. data/lib/action_controller/cookies.rb +10 -9
  26. data/lib/action_controller/{dependencies.rb → deprecated_dependencies.rb} +9 -27
  27. data/lib/action_controller/filters.rb +448 -225
  28. data/lib/action_controller/flash.rb +24 -20
  29. data/lib/action_controller/helpers.rb +2 -5
  30. data/lib/action_controller/integration.rb +40 -16
  31. data/lib/action_controller/layout.rb +11 -8
  32. data/lib/action_controller/macros/auto_complete.rb +3 -2
  33. data/lib/action_controller/macros/in_place_editing.rb +3 -2
  34. data/lib/action_controller/mime_responds.rb +41 -29
  35. data/lib/action_controller/mime_type.rb +68 -10
  36. data/lib/action_controller/pagination.rb +4 -3
  37. data/lib/action_controller/request.rb +22 -14
  38. data/lib/action_controller/rescue.rb +25 -22
  39. data/lib/action_controller/resources.rb +302 -0
  40. data/lib/action_controller/response.rb +20 -2
  41. data/lib/action_controller/response.rb.rej +17 -0
  42. data/lib/action_controller/routing.rb +1165 -567
  43. data/lib/action_controller/scaffolding.rb +30 -31
  44. data/lib/action_controller/session/active_record_store.rb +2 -0
  45. data/lib/action_controller/session/drb_store.rb +4 -0
  46. data/lib/action_controller/session/mem_cache_store.rb +4 -0
  47. data/lib/action_controller/session_management.rb +6 -9
  48. data/lib/action_controller/status_codes.rb +89 -0
  49. data/lib/action_controller/streaming.rb +6 -15
  50. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +5 -5
  51. data/lib/action_controller/templates/rescues/diagnostics.rhtml +2 -2
  52. data/lib/action_controller/templates/rescues/routing_error.rhtml +4 -4
  53. data/lib/action_controller/templates/rescues/template_error.rhtml +1 -1
  54. data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
  55. data/lib/action_controller/test_process.rb +52 -30
  56. data/lib/action_controller/url_rewriter.rb +63 -29
  57. data/lib/action_controller/vendor/html-scanner/html/document.rb +1 -0
  58. data/lib/action_controller/vendor/html-scanner/html/node.rb +3 -4
  59. data/lib/action_controller/vendor/html-scanner/html/selector.rb +822 -0
  60. data/lib/action_controller/verification.rb +22 -11
  61. data/lib/action_pack.rb +1 -1
  62. data/lib/action_pack/version.rb +2 -2
  63. data/lib/action_view.rb +1 -1
  64. data/lib/action_view/base.rb +46 -43
  65. data/lib/action_view/compiled_templates.rb +1 -1
  66. data/lib/action_view/helpers/active_record_helper.rb +54 -17
  67. data/lib/action_view/helpers/asset_tag_helper.rb +97 -46
  68. data/lib/action_view/helpers/capture_helper.rb +1 -1
  69. data/lib/action_view/helpers/date_helper.rb +258 -136
  70. data/lib/action_view/helpers/debug_helper.rb +1 -1
  71. data/lib/action_view/helpers/deprecated_helper.rb +34 -0
  72. data/lib/action_view/helpers/form_helper.rb +75 -35
  73. data/lib/action_view/helpers/form_options_helper.rb +7 -5
  74. data/lib/action_view/helpers/form_tag_helper.rb +44 -6
  75. data/lib/action_view/helpers/java_script_macros_helper.rb +59 -46
  76. data/lib/action_view/helpers/javascript_helper.rb +71 -10
  77. data/lib/action_view/helpers/javascripts/controls.js +41 -23
  78. data/lib/action_view/helpers/javascripts/dragdrop.js +105 -76
  79. data/lib/action_view/helpers/javascripts/effects.js +293 -163
  80. data/lib/action_view/helpers/javascripts/prototype.js +897 -389
  81. data/lib/action_view/helpers/javascripts/prototype.js.rej +561 -0
  82. data/lib/action_view/helpers/number_helper.rb +111 -65
  83. data/lib/action_view/helpers/prototype_helper.rb +84 -109
  84. data/lib/action_view/helpers/scriptaculous_helper.rb +5 -0
  85. data/lib/action_view/helpers/tag_helper.rb +69 -16
  86. data/lib/action_view/helpers/text_helper.rb +149 -112
  87. data/lib/action_view/helpers/url_helper.rb +200 -107
  88. data/lib/action_view/template_error.rb +66 -42
  89. data/test/abstract_unit.rb +4 -2
  90. data/test/active_record_unit.rb +84 -56
  91. data/test/activerecord/active_record_assertions_test.rb +26 -18
  92. data/test/activerecord/active_record_store_test.rb +4 -36
  93. data/test/activerecord/pagination_test.rb +1 -6
  94. data/test/controller/action_pack_assertions_test.rb +230 -113
  95. data/test/controller/addresses_render_test.rb +2 -6
  96. data/test/controller/assert_select_test.rb +576 -0
  97. data/test/controller/base_test.rb +73 -3
  98. data/test/controller/caching_test.rb +228 -0
  99. data/test/controller/capture_test.rb +12 -10
  100. data/test/controller/cgi_test.rb +89 -12
  101. data/test/controller/components_test.rb +24 -2
  102. data/test/controller/content_type_test.rb +139 -0
  103. data/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  104. data/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  105. data/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  106. data/test/controller/cookie_test.rb +33 -25
  107. data/test/controller/deprecated_instance_variables_test.rb +48 -0
  108. data/test/controller/deprecation/deprecated_base_methods_test.rb +60 -0
  109. data/test/controller/fake_controllers.rb +0 -1
  110. data/test/controller/filters_test.rb +301 -16
  111. data/test/controller/flash_test.rb +19 -2
  112. data/test/controller/helper_test.rb +2 -2
  113. data/test/controller/integration_test.rb +154 -0
  114. data/test/controller/layout_test.rb +115 -1
  115. data/test/controller/mime_responds_test.rb +94 -0
  116. data/test/controller/mime_type_test.rb +9 -0
  117. data/test/controller/new_render_test.rb +161 -11
  118. data/test/controller/raw_post_test.rb +52 -15
  119. data/test/controller/redirect_test.rb +27 -14
  120. data/test/controller/render_test.rb +76 -29
  121. data/test/controller/request_test.rb +55 -4
  122. data/test/controller/resources_test.rb +274 -0
  123. data/test/controller/routing_test.rb +1533 -824
  124. data/test/controller/selector_test.rb +628 -0
  125. data/test/controller/send_file_test.rb +9 -1
  126. data/test/controller/session_management_test.rb +51 -0
  127. data/test/controller/test_test.rb +113 -29
  128. data/test/controller/url_rewriter_test.rb +86 -17
  129. data/test/controller/verification_test.rb +19 -17
  130. data/test/controller/webservice_test.rb +0 -7
  131. data/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
  132. data/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
  133. data/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
  134. data/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
  135. data/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml +1 -0
  136. data/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml +1 -0
  137. data/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml +1 -0
  138. data/test/fixtures/deprecated_instance_variables/_flash_method.rhtml +1 -0
  139. data/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml +1 -0
  140. data/test/fixtures/deprecated_instance_variables/_headers_method.rhtml +1 -0
  141. data/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml +1 -0
  142. data/test/fixtures/deprecated_instance_variables/_params_method.rhtml +1 -0
  143. data/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml +1 -0
  144. data/test/fixtures/deprecated_instance_variables/_request_method.rhtml +1 -0
  145. data/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml +1 -0
  146. data/test/fixtures/deprecated_instance_variables/_response_method.rhtml +1 -0
  147. data/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml +1 -0
  148. data/test/fixtures/deprecated_instance_variables/_session_method.rhtml +1 -0
  149. data/test/fixtures/multipart/binary_file +0 -0
  150. data/test/fixtures/public/javascripts/application.js +1 -0
  151. data/test/fixtures/test/_hello.rxml +1 -0
  152. data/test/fixtures/test/hello_world_container.rxml +3 -0
  153. data/test/fixtures/topic.rb +2 -2
  154. data/test/template/active_record_helper_test.rb +83 -12
  155. data/test/template/asset_tag_helper_test.rb +75 -95
  156. data/test/template/compiled_templates_test.rb +1 -0
  157. data/test/template/date_helper_test.rb +873 -181
  158. data/test/template/deprecated_helper_test.rb +36 -0
  159. data/test/template/deprecated_instance_variables_test.rb +43 -0
  160. data/test/template/form_helper_test.rb +77 -1
  161. data/test/template/form_options_helper_test.rb +4 -0
  162. data/test/template/form_tag_helper_test.rb +66 -2
  163. data/test/template/java_script_macros_helper_test.rb +4 -1
  164. data/test/template/javascript_helper_test.rb +29 -0
  165. data/test/template/number_helper_test.rb +63 -27
  166. data/test/template/prototype_helper_test.rb +77 -34
  167. data/test/template/tag_helper_test.rb +34 -6
  168. data/test/template/text_helper_test.rb +69 -34
  169. data/test/template/url_helper_test.rb +168 -16
  170. data/test/testing_sandbox.rb +7 -22
  171. metadata +66 -20
  172. data/filler.txt +0 -50
  173. data/lib/action_controller/code_generation.rb +0 -235
  174. data/lib/action_controller/vendor/xml_simple.rb +0 -1019
  175. data/test/controller/caching_filestore.rb +0 -74
  176. data/test/fixtures/application_root/app/controllers/a_class_that_contains_a_controller/poorly_placed_controller.rb +0 -7
  177. data/test/fixtures/application_root/app/controllers/module_that_holds_controllers/nested_controller.rb +0 -3
  178. data/test/fixtures/application_root/app/models/a_class_that_contains_a_controller.rb +0 -7
  179. data/test/fixtures/dont_load.rb +0 -3
@@ -1,7 +1,6 @@
1
1
  module ActionController
2
2
  module Scaffolding # :nodoc:
3
- def self.append_features(base)
4
- super
3
+ def self.included(base)
5
4
  base.extend(ClassMethods)
6
5
  end
7
6
 
@@ -25,25 +24,25 @@ module ActionController
25
24
  # end
26
25
  #
27
26
  # def list
28
- # @entries = Entry.find_all
27
+ # @entries = Entry.find(:all)
29
28
  # render_scaffold "list"
30
29
  # end
31
- #
30
+ #
32
31
  # def show
33
32
  # @entry = Entry.find(params[:id])
34
33
  # render_scaffold
35
34
  # end
36
- #
35
+ #
37
36
  # def destroy
38
37
  # Entry.find(params[:id]).destroy
39
38
  # redirect_to :action => "list"
40
39
  # end
41
- #
40
+ #
42
41
  # def new
43
42
  # @entry = Entry.new
44
43
  # render_scaffold
45
44
  # end
46
- #
45
+ #
47
46
  # def create
48
47
  # @entry = Entry.new(params[:entry])
49
48
  # if @entry.save
@@ -53,16 +52,16 @@ module ActionController
53
52
  # render_scaffold('new')
54
53
  # end
55
54
  # end
56
- #
55
+ #
57
56
  # def edit
58
57
  # @entry = Entry.find(params[:id])
59
58
  # render_scaffold
60
59
  # end
61
- #
60
+ #
62
61
  # def update
63
62
  # @entry = Entry.find(params[:id])
64
63
  # @entry.attributes = params[:entry]
65
- #
64
+ #
66
65
  # if @entry.save
67
66
  # flash[:notice] = "Entry was successfully updated"
68
67
  # redirect_to :action => "show", :id => @entry
@@ -72,17 +71,17 @@ module ActionController
72
71
  # end
73
72
  # end
74
73
  #
75
- # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.rhtml" for
76
- # the show action) and if not, then render the generic template for that action. This gives you the possibility of using the
77
- # scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template
74
+ # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.rhtml" for
75
+ # the show action) and if not, then render the generic template for that action. This gives you the possibility of using the
76
+ # scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template
78
77
  # and one action at a time while relying on the rest of the scaffolded templates and actions.
79
78
  module ClassMethods
80
79
  # Adds a swath of generic CRUD actions to the controller. The +model_id+ is automatically converted into a class name unless
81
80
  # one is specifically provide through <tt>options[:class_name]</tt>. So <tt>scaffold :post</tt> would use Post as the class
82
81
  # and @post/@posts for the instance variables.
83
- #
82
+ #
84
83
  # It's possible to use more than one scaffold in a single controller by specifying <tt>options[:suffix] = true</tt>. This will
85
- # make <tt>scaffold :post, :suffix => true</tt> use method names like list_post, show_post, and create_post
84
+ # make <tt>scaffold :post, :suffix => true</tt> use method names like list_post, show_post, and create_post
86
85
  # instead of just list, show, and post. If suffix is used, then no index method is added.
87
86
  def scaffold(model_id, options = {})
88
87
  options.assert_valid_keys(:class_name, :suffix)
@@ -99,13 +98,13 @@ module ActionController
99
98
  end
100
99
  end_eval
101
100
  end
102
-
101
+
103
102
  module_eval <<-"end_eval", __FILE__, __LINE__
104
-
103
+
105
104
  verify :method => :post, :only => [ :destroy#{suffix}, :create#{suffix}, :update#{suffix} ],
106
105
  :redirect_to => { :action => :list#{suffix} }
107
-
108
-
106
+
107
+
109
108
  def list#{suffix}
110
109
  @#{singular_name}_pages, @#{plural_name} = paginate :#{plural_name}, :per_page => 10
111
110
  render#{suffix}_scaffold "list#{suffix}"
@@ -115,17 +114,17 @@ module ActionController
115
114
  @#{singular_name} = #{class_name}.find(params[:id])
116
115
  render#{suffix}_scaffold
117
116
  end
118
-
117
+
119
118
  def destroy#{suffix}
120
119
  #{class_name}.find(params[:id]).destroy
121
120
  redirect_to :action => "list#{suffix}"
122
121
  end
123
-
122
+
124
123
  def new#{suffix}
125
124
  @#{singular_name} = #{class_name}.new
126
125
  render#{suffix}_scaffold
127
126
  end
128
-
127
+
129
128
  def create#{suffix}
130
129
  @#{singular_name} = #{class_name}.new(params[:#{singular_name}])
131
130
  if @#{singular_name}.save
@@ -135,12 +134,12 @@ module ActionController
135
134
  render#{suffix}_scaffold('new')
136
135
  end
137
136
  end
138
-
137
+
139
138
  def edit#{suffix}
140
139
  @#{singular_name} = #{class_name}.find(params[:id])
141
140
  render#{suffix}_scaffold
142
141
  end
143
-
142
+
144
143
  def update#{suffix}
145
144
  @#{singular_name} = #{class_name}.find(params[:id])
146
145
  @#{singular_name}.attributes = params[:#{singular_name}]
@@ -152,14 +151,14 @@ module ActionController
152
151
  render#{suffix}_scaffold('edit')
153
152
  end
154
153
  end
155
-
154
+
156
155
  private
157
156
  def render#{suffix}_scaffold(action=nil)
158
157
  action ||= caller_method_name(caller)
159
158
  # logger.info ("testing template:" + "\#{self.class.controller_path}/\#{action}") if logger
160
-
159
+
161
160
  if template_exists?("\#{self.class.controller_path}/\#{action}")
162
- render_action(action)
161
+ render :action => action
163
162
  else
164
163
  @scaffold_class = #{class_name}
165
164
  @scaffold_singular_name, @scaffold_plural_name = "#{singular_name}", "#{plural_name}"
@@ -169,9 +168,9 @@ module ActionController
169
168
  @template.instance_variable_set("@content_for_layout", @template.render_file(scaffold_path(action.sub(/#{suffix}$/, "")), false))
170
169
 
171
170
  if !active_layout.nil?
172
- render_file(active_layout, nil, true)
171
+ render :file => active_layout, :use_full_path => true
173
172
  else
174
- render_file(scaffold_path("layout"))
173
+ render :file => scaffold_path('layout')
175
174
  end
176
175
  end
177
176
  end
@@ -179,12 +178,12 @@ module ActionController
179
178
  def scaffold_path(template_name)
180
179
  File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".rhtml"
181
180
  end
182
-
181
+
183
182
  def caller_method_name(caller)
184
183
  caller.first.scan(/`(.*)'/).first.first # ' ruby-mode
185
184
  end
186
185
  end_eval
187
- end
186
+ end
188
187
  end
189
188
  end
190
189
  end
@@ -5,6 +5,8 @@ require 'base64'
5
5
 
6
6
  class CGI
7
7
  class Session
8
+ attr_reader :data
9
+
8
10
  # Return this session's underlying Session instance. Useful for the DB-backed session stores.
9
11
  def model
10
12
  @dbman.model if @dbman
@@ -26,6 +26,10 @@ class CGI #:nodoc:all
26
26
  def delete
27
27
  @@session_data.delete(@session_id)
28
28
  end
29
+
30
+ def data
31
+ @@session_data[@session_id]
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -93,6 +93,10 @@ begin
93
93
  end
94
94
  @session_data = {}
95
95
  end
96
+
97
+ def data
98
+ @session_data
99
+ end
96
100
  end
97
101
  end
98
102
  end
@@ -8,12 +8,9 @@ module ActionController #:nodoc:
8
8
  module SessionManagement #:nodoc:
9
9
  def self.included(base)
10
10
  base.extend(ClassMethods)
11
-
12
- base.send :alias_method, :process_without_session_management_support, :process
13
- base.send :alias_method, :process, :process_with_session_management_support
14
-
15
- base.send :alias_method, :process_cleanup_without_session_management_support, :process_cleanup
16
- base.send :alias_method, :process_cleanup, :process_cleanup_with_session_management_support
11
+
12
+ base.send :alias_method_chain, :process, :session_management_support
13
+ base.send :alias_method_chain, :process_cleanup, :session_management_support
17
14
  end
18
15
 
19
16
  module ClassMethods
@@ -123,16 +120,16 @@ module ActionController #:nodoc:
123
120
  end
124
121
 
125
122
  def process_cleanup_with_session_management_support
126
- process_cleanup_without_session_management_support
127
123
  clear_persistent_model_associations
124
+ process_cleanup_without_session_management_support
128
125
  end
129
126
 
130
127
  # Clear cached associations in session data so they don't overflow
131
128
  # the database field. Only applies to ActiveRecordStore since there
132
129
  # is not a standard way to iterate over session data.
133
130
  def clear_persistent_model_associations #:doc:
134
- if defined?(@session) && @session.instance_variables.include?('@data')
135
- session_data = @session.instance_variable_get('@data')
131
+ if defined?(@_session) && @_session.respond_to?(:data)
132
+ session_data = @_session.data
136
133
 
137
134
  if session_data && session_data.respond_to?(:each_value)
138
135
  session_data.each_value do |obj|
@@ -0,0 +1,89 @@
1
+ module ActionController
2
+ module StatusCodes
3
+
4
+ # Defines the standard HTTP status codes, by integer, with their
5
+ # corresponding default message texts.
6
+ # Source: http://www.iana.org/assignments/http-status-codes
7
+ STATUS_CODES = {
8
+ 100 => "Continue",
9
+ 101 => "Switching Protocols",
10
+ 102 => "Processing",
11
+
12
+ 200 => "OK",
13
+ 201 => "Created",
14
+ 202 => "Accepted",
15
+ 203 => "Non-Authoritative Information",
16
+ 204 => "No Content",
17
+ 205 => "Reset Content",
18
+ 206 => "Partial Content",
19
+ 207 => "Multi-Status",
20
+ 226 => "IM Used",
21
+
22
+ 300 => "Multiple Choices",
23
+ 301 => "Moved Permanently",
24
+ 302 => "Found",
25
+ 303 => "See Other",
26
+ 304 => "Not Modified",
27
+ 305 => "Use Proxy",
28
+ 307 => "Temporary Redirect",
29
+
30
+ 400 => "Bad Request",
31
+ 401 => "Unauthorized",
32
+ 402 => "Payment Required",
33
+ 403 => "Forbidden",
34
+ 404 => "Not Found",
35
+ 405 => "Method Not Allowed",
36
+ 406 => "Not Acceptable",
37
+ 407 => "Proxy Authentication Required",
38
+ 408 => "Request Timeout",
39
+ 409 => "Conflict",
40
+ 410 => "Gone",
41
+ 411 => "Length Required",
42
+ 412 => "Precondition Failed",
43
+ 413 => "Request Entity Too Large",
44
+ 414 => "Request-URI Too Long",
45
+ 415 => "Unsupported Media Type",
46
+ 416 => "Requested Range Not Satisfiable",
47
+ 417 => "Expectation Failed",
48
+ 422 => "Unprocessable Entity",
49
+ 423 => "Locked",
50
+ 424 => "Failed Dependency",
51
+ 426 => "Upgrade Required",
52
+
53
+ 500 => "Internal Server Error",
54
+ 501 => "Not Implemented",
55
+ 502 => "Bad Gateway",
56
+ 503 => "Service Unavailable",
57
+ 504 => "Gateway Timeout",
58
+ 505 => "HTTP Version Not Supported",
59
+ 507 => "Insufficient Storage",
60
+ 510 => "Not Extended"
61
+ }
62
+
63
+ # Provides a symbol-to-fixnum lookup for converting a symbol (like
64
+ # :created or :not_implemented) into its corresponding HTTP status
65
+ # code (like 200 or 501).
66
+ SYMBOL_TO_STATUS_CODE = STATUS_CODES.inject({}) do |hash, (code, message)|
67
+ hash[message.gsub(/ /, "").underscore.to_sym] = code
68
+ hash
69
+ end
70
+
71
+ # Given a status parameter, determine whether it needs to be converted
72
+ # to a string. If it is a fixnum, use the STATUS_CODES hash to lookup
73
+ # the default message. If it is a symbol, use the SYMBOL_TO_STATUS_CODE
74
+ # hash to convert it.
75
+ def interpret_status(status)
76
+ case status
77
+ when Fixnum then
78
+ "#{status} #{STATUS_CODES[status]}".strip
79
+ when Symbol then
80
+ interpret_status(SYMBOL_TO_STATUS_CODE[status] ||
81
+ "500 Unknown Status #{status.inspect}")
82
+ else
83
+ status.to_s
84
+ end
85
+ end
86
+ private :interpret_status
87
+
88
+ end
89
+ end
@@ -69,17 +69,8 @@ module ActionController #:nodoc:
69
69
  logger.info "Streaming file #{path}" unless logger.nil?
70
70
  len = options[:buffer_size] || 4096
71
71
  File.open(path, 'rb') do |file|
72
- if output.respond_to?(:syswrite)
73
- begin
74
- while true
75
- output.syswrite(file.sysread(len))
76
- end
77
- rescue EOFError
78
- end
79
- else
80
- while buf = file.read(len)
81
- output.write(buf)
82
- end
72
+ while buf = file.read(len)
73
+ output.write(buf)
83
74
  end
84
75
  end
85
76
  }
@@ -97,8 +88,8 @@ module ActionController #:nodoc:
97
88
  # * <tt>:type</tt> - specifies an HTTP content type.
98
89
  # Defaults to 'application/octet-stream'.
99
90
  # * <tt>:disposition</tt> - specifies whether the file will be shown inline or downloaded.
100
- # * <tt>:status</tt> - specifies the status code to send with the response. Defaults to '200 OK'.
101
91
  # Valid values are 'inline' and 'attachment' (default).
92
+ # * <tt>:status</tt> - specifies the status code to send with the response. Defaults to '200 OK'.
102
93
  #
103
94
  # Generic data download:
104
95
  # send_data buffer
@@ -125,10 +116,10 @@ module ActionController #:nodoc:
125
116
  end
126
117
 
127
118
  disposition = options[:disposition].dup || 'attachment'
128
-
119
+
129
120
  disposition <<= %(; filename="#{options[:filename]}") if options[:filename]
130
121
 
131
- @headers.update(
122
+ headers.update(
132
123
  'Content-Length' => options[:length],
133
124
  'Content-Type' => options[:type].strip, # fixes a problem with extra '\r' with some browsers
134
125
  'Content-Disposition' => disposition,
@@ -141,7 +132,7 @@ module ActionController #:nodoc:
141
132
  # after it displays the "open/save" dialog, which means that if you
142
133
  # hit "open" the file isn't there anymore when the application that
143
134
  # is called for handling the download is run, so let's workaround that
144
- @headers['Cache-Control'] = 'private' if @headers['Cache-Control'] == 'no-cache'
135
+ headers['Cache-Control'] = 'private' if headers['Cache-Control'] == 'no-cache'
145
136
  end
146
137
  end
147
138
  end
@@ -8,10 +8,10 @@
8
8
  <% if false %>
9
9
  <br /><br />
10
10
  <% begin %>
11
- <%= form_tag(@request.request_uri, "method" => @request.method) %>
11
+ <%= form_tag(request.request_uri, "method" => request.method) %>
12
12
  <input type="hidden" name="BP-RETRY" value="1" />
13
13
 
14
- <% for key, values in @params %>
14
+ <% for key, values in params %>
15
15
  <% next if key == "BP-RETRY" %>
16
16
  <% for value in Array(values) %>
17
17
  <input type="hidden" name="<%= key %>" value="<%= value %>" />
@@ -26,7 +26,7 @@
26
26
  <% end %>
27
27
 
28
28
  <%
29
- request_parameters_without_action = @request.parameters.clone
29
+ request_parameters_without_action = request.parameters.clone
30
30
  request_parameters_without_action.delete("action")
31
31
  request_parameters_without_action.delete("controller")
32
32
 
@@ -37,8 +37,8 @@
37
37
  <p><b>Parameters</b>: <%=h request_dump == "{}" ? "None" : request_dump %></p>
38
38
 
39
39
  <p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>
40
- <div id="session_dump" style="display:none"><%= debug(@request.session.instance_variable_get("@data")) %></div>
40
+ <div id="session_dump" style="display:none"><%= debug(request.session.instance_variable_get("@data")) %></div>
41
41
 
42
42
 
43
43
  <h2 style="margin-top: 30px">Response</h2>
44
- <b>Headers</b>: <%=h @response.headers.inspect.gsub(/,/, ",\n") %><br/>
44
+ <b>Headers</b>: <%=h response ? response.headers.inspect.gsub(/,/, ",\n") : "None" %><br/>
@@ -1,7 +1,7 @@
1
1
  <h1>
2
2
  <%=h @exception.class.to_s %>
3
- <% if @request.parameters['controller'] %>
4
- in <%=h @request.parameters['controller'].humanize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %>
3
+ <% if request.parameters['controller'] %>
4
+ in <%=h request.parameters['controller'].humanize %>Controller<% if request.parameters['action'] %>#<%=h request.parameters['action'] %><% end %>
5
5
  <% end %>
6
6
  </h1>
7
7
  <pre><%=h @exception.clean_message %></pre>
@@ -1,10 +1,10 @@
1
1
  <h1>Routing Error</h1>
2
2
  <p><pre><%=h @exception.message %></pre></p>
3
3
  <% unless @exception.failures.empty? %><p>
4
- <h2>Failure reasons:</h2>
5
- <ol>
6
- <% @exception.failures.each do |route, reason| %>
7
- <li><code><%=h route.inspect.gsub('\\', '') %></code> failed because <%=h reason.downcase %></li>
4
+ <h2>Failure reasons:</h2>
5
+ <ol>
6
+ <% @exception.failures.each do |route, reason| %>
7
+ <li><code><%=h route.inspect.gsub('\\', '') %></code> failed because <%=h reason.downcase %></li>
8
8
  <% end %>
9
9
  </ol>
10
10
  </p><% end %>
@@ -1,6 +1,6 @@
1
1
  <h1>
2
2
  <%=h @exception.original_exception.class.to_s %> in
3
- <%=h @request.parameters["controller"].capitalize if @request.parameters["controller"]%>#<%=h @request.parameters["action"] %>
3
+ <%=h request.parameters["controller"].capitalize if request.parameters["controller"]%>#<%=h request.parameters["action"] %>
4
4
  </h1>
5
5
 
6
6
  <p>