actionpack 3.0.20 → 3.1.0.beta1

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 (161) hide show
  1. data/CHANGELOG +88 -142
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +5 -6
  4. data/lib/abstract_controller.rb +1 -0
  5. data/lib/abstract_controller/asset_paths.rb +2 -2
  6. data/lib/abstract_controller/base.rb +24 -19
  7. data/lib/abstract_controller/callbacks.rb +19 -19
  8. data/lib/abstract_controller/helpers.rb +11 -13
  9. data/lib/abstract_controller/layouts.rb +4 -5
  10. data/lib/abstract_controller/railties/routes_helpers.rb +18 -0
  11. data/lib/abstract_controller/rendering.rb +34 -31
  12. data/lib/abstract_controller/url_for.rb +27 -0
  13. data/lib/abstract_controller/view_paths.rb +31 -6
  14. data/lib/action_controller.rb +5 -3
  15. data/lib/action_controller/base.rb +15 -16
  16. data/lib/action_controller/caching.rb +2 -2
  17. data/lib/action_controller/caching/actions.rb +11 -12
  18. data/lib/action_controller/caching/fragments.rb +41 -19
  19. data/lib/action_controller/caching/pages.rb +3 -9
  20. data/lib/action_controller/caching/sweeping.rb +0 -1
  21. data/lib/action_controller/deprecated.rb +1 -1
  22. data/lib/action_controller/log_subscriber.rb +1 -1
  23. data/lib/action_controller/metal.rb +78 -20
  24. data/lib/action_controller/metal/compatibility.rb +0 -9
  25. data/lib/action_controller/metal/conditional_get.rb +9 -9
  26. data/lib/action_controller/metal/data_streaming.rb +145 -0
  27. data/lib/action_controller/metal/force_ssl.rb +35 -0
  28. data/lib/action_controller/metal/head.rb +1 -1
  29. data/lib/action_controller/metal/helpers.rb +37 -44
  30. data/lib/action_controller/metal/hide_actions.rb +2 -3
  31. data/lib/action_controller/metal/http_authentication.rb +41 -38
  32. data/lib/action_controller/metal/implicit_render.rb +13 -13
  33. data/lib/action_controller/metal/instrumentation.rb +2 -2
  34. data/lib/action_controller/metal/mime_responds.rb +25 -19
  35. data/lib/action_controller/metal/params_wrapper.rb +224 -0
  36. data/lib/action_controller/metal/redirecting.rb +6 -2
  37. data/lib/action_controller/metal/renderers.rb +50 -36
  38. data/lib/action_controller/metal/rendering.rb +34 -25
  39. data/lib/action_controller/metal/request_forgery_protection.rb +18 -36
  40. data/lib/action_controller/metal/responder.rb +47 -12
  41. data/lib/action_controller/metal/streaming.rb +244 -138
  42. data/lib/action_controller/metal/testing.rb +0 -9
  43. data/lib/action_controller/metal/url_for.rb +12 -14
  44. data/lib/action_controller/railtie.rb +19 -37
  45. data/lib/action_controller/railties/paths.rb +24 -0
  46. data/lib/action_controller/record_identifier.rb +4 -10
  47. data/lib/action_controller/test_case.rb +36 -19
  48. data/lib/action_controller/vendor/html-scanner/html/node.rb +5 -5
  49. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +3 -3
  50. data/lib/action_controller/vendor/html-scanner/html/selector.rb +2 -0
  51. data/lib/action_dispatch.rb +4 -1
  52. data/lib/action_dispatch/http/cache.rb +5 -32
  53. data/lib/action_dispatch/http/filter_parameters.rb +3 -1
  54. data/lib/action_dispatch/http/mime_negotiation.rb +22 -3
  55. data/lib/action_dispatch/http/mime_type.rb +45 -5
  56. data/lib/action_dispatch/http/rack_cache.rb +58 -0
  57. data/lib/action_dispatch/http/request.rb +27 -41
  58. data/lib/action_dispatch/http/response.rb +56 -54
  59. data/lib/action_dispatch/http/upload.rb +1 -11
  60. data/lib/action_dispatch/http/url.rb +102 -42
  61. data/lib/action_dispatch/middleware/callbacks.rb +8 -25
  62. data/lib/action_dispatch/middleware/closed_error.rb +7 -0
  63. data/lib/action_dispatch/middleware/cookies.rb +37 -15
  64. data/lib/action_dispatch/middleware/flash.rb +80 -11
  65. data/lib/action_dispatch/middleware/params_parser.rb +2 -2
  66. data/lib/action_dispatch/middleware/reloader.rb +76 -0
  67. data/lib/action_dispatch/middleware/session/abstract_store.rb +56 -226
  68. data/lib/action_dispatch/middleware/session/cookie_store.rb +20 -44
  69. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -46
  70. data/lib/action_dispatch/middleware/show_exceptions.rb +15 -2
  71. data/lib/action_dispatch/middleware/stack.rb +50 -17
  72. data/lib/action_dispatch/middleware/static.rb +41 -29
  73. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +3 -3
  74. data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +3 -3
  75. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +3 -3
  76. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +4 -2
  77. data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +2 -6
  78. data/lib/action_dispatch/railtie.rb +8 -0
  79. data/lib/action_dispatch/routing.rb +13 -1
  80. data/lib/action_dispatch/routing/mapper.rb +345 -227
  81. data/lib/action_dispatch/routing/polymorphic_routes.rb +33 -13
  82. data/lib/action_dispatch/routing/redirection.rb +110 -0
  83. data/lib/action_dispatch/routing/route.rb +15 -13
  84. data/lib/action_dispatch/routing/route_set.rb +116 -90
  85. data/lib/action_dispatch/routing/routes_proxy.rb +35 -0
  86. data/lib/action_dispatch/routing/url_for.rb +25 -1
  87. data/lib/action_dispatch/testing/assertions/response.rb +8 -10
  88. data/lib/action_dispatch/testing/assertions/routing.rb +15 -15
  89. data/lib/action_dispatch/testing/assertions/selector.rb +13 -220
  90. data/lib/action_dispatch/testing/integration.rb +37 -28
  91. data/lib/action_dispatch/testing/performance_test.rb +1 -3
  92. data/lib/action_dispatch/testing/test_process.rb +1 -1
  93. data/lib/action_dispatch/testing/test_request.rb +9 -3
  94. data/lib/action_dispatch/testing/test_response.rb +4 -111
  95. data/lib/action_pack.rb +1 -1
  96. data/lib/action_pack/version.rb +3 -3
  97. data/lib/action_view.rb +39 -24
  98. data/lib/action_view/base.rb +61 -86
  99. data/lib/action_view/buffers.rb +43 -0
  100. data/lib/action_view/context.rb +21 -24
  101. data/lib/action_view/flows.rb +79 -0
  102. data/lib/action_view/helpers.rb +8 -6
  103. data/lib/action_view/helpers/active_model_helper.rb +0 -23
  104. data/lib/action_view/helpers/asset_paths.rb +79 -0
  105. data/lib/action_view/helpers/asset_tag_helper.rb +30 -500
  106. data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +147 -0
  107. data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +101 -0
  108. data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +200 -0
  109. data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +152 -0
  110. data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
  111. data/lib/action_view/helpers/cache_helper.rb +11 -19
  112. data/lib/action_view/helpers/capture_helper.rb +19 -8
  113. data/lib/action_view/helpers/controller_helper.rb +21 -0
  114. data/lib/action_view/helpers/csrf_helper.rb +22 -4
  115. data/lib/action_view/helpers/date_helper.rb +36 -22
  116. data/lib/action_view/helpers/form_helper.rb +199 -113
  117. data/lib/action_view/helpers/form_options_helper.rb +10 -11
  118. data/lib/action_view/helpers/form_tag_helper.rb +94 -22
  119. data/lib/action_view/helpers/javascript_helper.rb +24 -107
  120. data/lib/action_view/helpers/number_helper.rb +36 -33
  121. data/lib/action_view/helpers/output_safety_helper.rb +38 -0
  122. data/lib/action_view/helpers/record_tag_helper.rb +6 -6
  123. data/lib/action_view/helpers/rendering_helper.rb +90 -0
  124. data/lib/action_view/helpers/sanitize_helper.rb +2 -2
  125. data/lib/action_view/helpers/sprockets_helper.rb +69 -0
  126. data/lib/action_view/helpers/tag_helper.rb +34 -12
  127. data/lib/action_view/helpers/text_helper.rb +30 -145
  128. data/lib/action_view/helpers/translation_helper.rb +10 -17
  129. data/lib/action_view/helpers/url_helper.rb +70 -67
  130. data/lib/action_view/locale/en.yml +1 -1
  131. data/lib/action_view/lookup_context.rb +36 -14
  132. data/lib/action_view/{paths.rb → path_set.rb} +9 -8
  133. data/lib/action_view/railtie.rb +12 -4
  134. data/lib/action_view/renderer/abstract_renderer.rb +36 -0
  135. data/lib/action_view/{render/partials.rb → renderer/partial_renderer.rb} +147 -146
  136. data/lib/action_view/renderer/renderer.rb +54 -0
  137. data/lib/action_view/renderer/streaming_template_renderer.rb +106 -0
  138. data/lib/action_view/renderer/template_renderer.rb +74 -0
  139. data/lib/action_view/template.rb +91 -54
  140. data/lib/action_view/template/error.rb +11 -8
  141. data/lib/action_view/template/handler.rb +9 -1
  142. data/lib/action_view/template/handlers.rb +9 -9
  143. data/lib/action_view/template/handlers/builder.rb +4 -4
  144. data/lib/action_view/template/handlers/erb.rb +21 -41
  145. data/lib/action_view/template/resolver.rb +171 -57
  146. data/lib/action_view/template/text.rb +0 -4
  147. data/lib/action_view/test_case.rb +32 -16
  148. data/lib/action_view/testing/resolvers.rb +16 -10
  149. data/lib/sprockets/railtie.rb +100 -0
  150. metadata +162 -140
  151. checksums.yaml +0 -7
  152. data/lib/action_controller/deprecated/base.rb +0 -143
  153. data/lib/action_controller/deprecated/dispatcher.rb +0 -28
  154. data/lib/action_controller/deprecated/url_writer.rb +0 -14
  155. data/lib/action_dispatch/routing/deprecated_mapper.rb +0 -525
  156. data/lib/action_view/helpers/prototype_helper.rb +0 -851
  157. data/lib/action_view/helpers/raw_output_helper.rb +0 -18
  158. data/lib/action_view/helpers/scriptaculous_helper.rb +0 -263
  159. data/lib/action_view/render/layouts.rb +0 -83
  160. data/lib/action_view/render/rendering.rb +0 -67
  161. data/lib/action_view/template/handlers/rjs.rb +0 -17
@@ -14,18 +14,9 @@ module ActionController
14
14
  cookies.write(@_response)
15
15
  end
16
16
  @_response.prepare!
17
- set_test_assigns
18
17
  ret
19
18
  end
20
19
 
21
- def set_test_assigns
22
- @assigns = {}
23
- (instance_variable_names - self.class.protected_instance_variables).each do |var|
24
- name, value = var[1..-1], instance_variable_get(var)
25
- @assigns[name] = value
26
- end
27
- end
28
-
29
20
  # TODO : Rewrite tests using controller.headers= to use Rack env
30
21
  def headers=(new_headers)
31
22
  @_response ||= ActionDispatch::Response.new
@@ -2,27 +2,25 @@ module ActionController
2
2
  module UrlFor
3
3
  extend ActiveSupport::Concern
4
4
 
5
- include ActionDispatch::Routing::UrlFor
5
+ include AbstractController::UrlFor
6
6
 
7
7
  def url_options
8
- super.reverse_merge(
9
- :host => request.host_with_port,
8
+ @_url_options ||= super.reverse_merge(
9
+ :host => request.host,
10
+ :port => request.optional_port,
10
11
  :protocol => request.protocol,
11
12
  :_path_segments => request.symbolized_path_parameters
12
- ).merge(:script_name => request.script_name)
13
- end
14
-
15
- def _routes
16
- raise "In order to use #url_for, you must include routing helpers explicitly. " \
17
- "For instance, `include Rails.application.routes.url_helpers"
18
- end
13
+ ).freeze
19
14
 
20
- module ClassMethods
21
- def action_methods
22
- @action_methods ||= begin
23
- super - _routes.named_routes.helper_names
15
+ if _routes.equal?(env["action_dispatch.routes"])
16
+ @_url_options.dup.tap do |options|
17
+ options[:script_name] = request.script_name.dup
18
+ options.freeze
24
19
  end
20
+ else
21
+ @_url_options
25
22
  end
26
23
  end
24
+
27
25
  end
28
26
  end
@@ -2,35 +2,14 @@ require "rails"
2
2
  require "action_controller"
3
3
  require "action_dispatch/railtie"
4
4
  require "action_view/railtie"
5
- require "active_support/deprecation/proxy_wrappers"
6
- require "active_support/deprecation"
5
+ require "abstract_controller/railties/routes_helpers"
6
+ require "action_controller/railties/paths"
7
+ require "sprockets/railtie"
7
8
 
8
9
  module ActionController
9
10
  class Railtie < Rails::Railtie
10
11
  config.action_controller = ActiveSupport::OrderedOptions.new
11
12
 
12
- config.action_controller.singleton_class.tap do |d|
13
- d.send(:define_method, :session) do
14
- ActiveSupport::Deprecation.warn "config.action_controller.session has been deprecated. " <<
15
- "Please use Rails.application.config.session_store instead.", caller
16
- end
17
-
18
- d.send(:define_method, :session=) do |val|
19
- ActiveSupport::Deprecation.warn "config.action_controller.session= has been deprecated. " <<
20
- "Please use config.session_store(name, options) instead.", caller
21
- end
22
-
23
- d.send(:define_method, :session_store) do
24
- ActiveSupport::Deprecation.warn "config.action_controller.session_store has been deprecated. " <<
25
- "Please use Rails.application.config.session_store instead.", caller
26
- end
27
-
28
- d.send(:define_method, :session_store=) do |val|
29
- ActiveSupport::Deprecation.warn "config.action_controller.session_store= has been deprecated. " <<
30
- "Please use config.session_store(name, options) instead.", caller
31
- end
32
- end
33
-
34
13
  initializer "action_controller.logger" do
35
14
  ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
36
15
  end
@@ -43,24 +22,27 @@ module ActionController
43
22
  paths = app.config.paths
44
23
  options = app.config.action_controller
45
24
 
46
- options.assets_dir ||= paths.public.to_a.first
47
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
48
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
49
- options.page_cache_directory ||= paths.public.to_a.first
50
- options.helpers_path ||= paths.app.helpers.to_a
25
+ options.assets_dir ||= paths["public"].first
26
+ options.javascripts_dir ||= paths["public/javascripts"].first
27
+ options.stylesheets_dir ||= paths["public/stylesheets"].first
28
+ options.page_cache_directory ||= paths["public"].first
29
+
30
+ # make sure readers methods get compiled
31
+ options.asset_path ||= app.config.asset_path
32
+ options.asset_host ||= app.config.asset_host
51
33
 
52
34
  ActiveSupport.on_load(:action_controller) do
53
- include app.routes.url_helpers
35
+ include app.routes.mounted_helpers
36
+ extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
37
+ extend ::ActionController::Railties::Paths.with(app)
54
38
  options.each { |k,v| send("#{k}=", v) }
55
39
  end
56
40
  end
57
41
 
58
- initializer "action_controller.deprecated_routes" do |app|
59
- message = "ActionController::Routing::Routes is deprecated. " \
60
- "Instead, use Rails.application.routes"
61
-
62
- proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(app.routes, message)
63
- ActionController::Routing::Routes = proxy
42
+ initializer "action_controller.compile_config_methods" do
43
+ ActiveSupport.on_load(:action_controller) do
44
+ config.compile_methods! if config.respond_to?(:compile_methods!)
45
+ end
64
46
  end
65
47
  end
66
- end
48
+ end
@@ -0,0 +1,24 @@
1
+ module ActionController
2
+ module Railties
3
+ module Paths
4
+ def self.with(app)
5
+ Module.new do
6
+ define_method(:inherited) do |klass|
7
+ super(klass)
8
+
9
+ if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
10
+ paths = namespace._railtie.paths["app/helpers"].existent
11
+ else
12
+ paths = app.config.helpers_paths
13
+ end
14
+
15
+ klass.helpers_path = paths
16
+ if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
17
+ klass.helper :all
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -18,18 +18,12 @@ module ActionController
18
18
  # post = Post.find(params[:id])
19
19
  # post.destroy
20
20
  #
21
- # respond_to do |format|
22
- # format.html { redirect_to(post) } # Calls polymorphic_url(post) which in turn calls post_url(post)
23
- # format.js do
24
- # # Calls: new Effect.fade('post_45');
25
- # render(:update) { |page| page[post].visual_effect(:fade) }
26
- # end
27
- # end
21
+ # redirect_to(post) # Calls polymorphic_url(post) which in turn calls post_url(post)
28
22
  # end
29
23
  #
30
- # As the example above shows, you can stop caring to a large extent what the actual id of the post is. You just know
31
- # that one is being assigned and that the subsequent calls in redirect_to and the RJS expect that same naming
32
- # convention and allows you to write less code if you follow it.
24
+ # As the example above shows, you can stop caring to a large extent what the actual id of the post is.
25
+ # You just know that one is being assigned and that the subsequent calls in redirect_to expect that
26
+ # same naming convention and allows you to write less code if you follow it.
33
27
  module RecordIdentifier
34
28
  extend self
35
29
 
@@ -1,6 +1,7 @@
1
1
  require 'rack/session/abstract/id'
2
2
  require 'active_support/core_ext/object/blank'
3
3
  require 'active_support/core_ext/object/to_query'
4
+ require 'active_support/core_ext/class/attribute'
4
5
 
5
6
  module ActionController
6
7
  module TemplateAssertions
@@ -134,7 +135,7 @@ module ActionController
134
135
  class Result < ::Array #:nodoc:
135
136
  def to_s() join '/' end
136
137
  def self.new_escaped(strings)
137
- new strings.collect {|str| URI.unescape str}
138
+ new strings.collect {|str| uri_parser.unescape str}
138
139
  end
139
140
  end
140
141
 
@@ -173,6 +174,10 @@ module ActionController
173
174
  end
174
175
 
175
176
  def recycle!
177
+ write_cookies!
178
+ @env.delete('HTTP_COOKIE') if @cookies.blank?
179
+ @env.delete('action_dispatch.cookies')
180
+ @cookies = nil
176
181
  @formats = nil
177
182
  @env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
178
183
  @env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
@@ -196,20 +201,23 @@ module ActionController
196
201
  end
197
202
  end
198
203
 
199
- class TestSession < ActionDispatch::Session::AbstractStore::SessionHash #:nodoc:
200
- DEFAULT_OPTIONS = ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS
204
+ class TestSession < Rack::Session::Abstract::SessionHash #:nodoc:
205
+ DEFAULT_OPTIONS = Rack::Session::Abstract::ID::DEFAULT_OPTIONS
201
206
 
202
207
  def initialize(session = {})
208
+ @env, @by = nil, nil
203
209
  replace(session.stringify_keys)
204
210
  @loaded = true
205
211
  end
206
212
 
207
- def exists?; true; end
213
+ def exists?
214
+ true
215
+ end
208
216
  end
209
217
 
210
218
  # Superclass for ActionController functional tests. Functional tests allow you to
211
219
  # test a single controller action per test method. This should not be confused with
212
- # integration tests (see ActionController::IntegrationTest), which are more like
220
+ # integration tests (see ActionDispatch::IntegrationTest), which are more like
213
221
  # "stories" that can involve multiple controllers and multiple actions (i.e. multiple
214
222
  # different HTTP requests).
215
223
  #
@@ -254,7 +262,7 @@ module ActionController
254
262
  # after calling +post+. If the various assert methods are not sufficient, then you
255
263
  # may use this object to inspect the HTTP response in detail.
256
264
  #
257
- # (Earlier versions of Rails required each functional test to subclass
265
+ # (Earlier versions of \Rails required each functional test to subclass
258
266
  # Test::Unit::TestCase and define @controller, @request, @response in +setup+.)
259
267
  #
260
268
  # == Controller is automatically inferred
@@ -267,7 +275,7 @@ module ActionController
267
275
  # tests WidgetController
268
276
  # end
269
277
  #
270
- # == Testing controller internals
278
+ # == \Testing controller internals
271
279
  #
272
280
  # In addition to these specific assertions, you also have easy access to various collections that the regular test/unit assertions
273
281
  # can be used against. These collections are:
@@ -275,7 +283,7 @@ module ActionController
275
283
  # * assigns: Instance variables assigned in the action that are available for the view.
276
284
  # * session: Objects being saved in the session.
277
285
  # * flash: The flash objects currently in the session.
278
- # * cookies: Cookies being sent to the user on this request.
286
+ # * cookies: \Cookies being sent to the user on this request.
279
287
  #
280
288
  # These collections can be used just like any other hash:
281
289
  #
@@ -299,9 +307,13 @@ module ActionController
299
307
  # and cookies, though. For sessions, you just do:
300
308
  #
301
309
  # @request.session[:key] = "value"
302
- # @request.cookies["key"] = "value"
310
+ # @request.cookies[:key] = "value"
311
+ #
312
+ # To clear the cookies for a test just clear the request's cookies hash:
303
313
  #
304
- # == Testing named routes
314
+ # @request.cookies.clear
315
+ #
316
+ # == \Testing named routes
305
317
  #
306
318
  # If you're using named routes, they can be easily tested using the original named routes' methods straight in the test case.
307
319
  # Example:
@@ -324,11 +336,11 @@ module ActionController
324
336
 
325
337
  def controller_class=(new_class)
326
338
  prepare_controller_class(new_class) if new_class
327
- write_inheritable_attribute(:controller_class, new_class)
339
+ self._controller_class = new_class
328
340
  end
329
341
 
330
342
  def controller_class
331
- if current_controller_class = read_inheritable_attribute(:controller_class)
343
+ if current_controller_class = self._controller_class
332
344
  current_controller_class
333
345
  else
334
346
  self.controller_class = determine_default_controller_class(name)
@@ -403,16 +415,18 @@ module ActionController
403
415
  parameters ||= {}
404
416
  @request.assign_parameters(@routes, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters)
405
417
 
406
- @request.session = ActionController::TestSession.new(session) unless session.nil?
418
+ @request.session = ActionController::TestSession.new(session) if session
407
419
  @request.session["flash"] = @request.flash.update(flash || {})
408
420
  @request.session["flash"].sweep
409
421
 
410
422
  @controller.request = @request
411
423
  @controller.params.merge!(parameters)
412
424
  build_request_uri(action, parameters)
413
- Base.class_eval { include Testing }
425
+ @controller.class.class_eval { include Testing }
414
426
  @controller.process_with_new_base_test(@request, @response)
427
+ @assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
415
428
  @request.session.delete('flash') if @request.session['flash'].blank?
429
+ @request.cookies.merge!(@response.cookies)
416
430
  @response
417
431
  end
418
432
 
@@ -426,7 +440,7 @@ module ActionController
426
440
 
427
441
  @request.env.delete('PATH_INFO')
428
442
 
429
- if @controller
443
+ if defined?(@controller) && @controller
430
444
  @controller.request = @request
431
445
  @controller.params = {}
432
446
  end
@@ -440,6 +454,7 @@ module ActionController
440
454
  included do
441
455
  include ActionController::TemplateAssertions
442
456
  include ActionDispatch::Assertions
457
+ class_attribute :_controller_class
443
458
  setup :setup_controller_request_and_response
444
459
  end
445
460
 
@@ -447,7 +462,7 @@ module ActionController
447
462
 
448
463
  def build_request_uri(action, parameters)
449
464
  unless @request.env["PATH_INFO"]
450
- options = @controller.__send__(:url_options).merge(parameters)
465
+ options = @controller.respond_to?(:url_options) ? @controller.__send__(:url_options).merge(parameters) : parameters
451
466
  options.update(
452
467
  :only_path => true,
453
468
  :action => action,
@@ -471,9 +486,11 @@ module ActionController
471
486
  # The exception is stored in the exception accessor for further inspection.
472
487
  module RaiseActionExceptions
473
488
  def self.included(base)
474
- base.class_eval do
475
- attr_accessor :exception
476
- protected :exception, :exception=
489
+ unless base.method_defined?(:exception) && base.method_defined?(:exception=)
490
+ base.class_eval do
491
+ attr_accessor :exception
492
+ protected :exception, :exception=
493
+ end
477
494
  end
478
495
  end
479
496
 
@@ -18,14 +18,14 @@ module HTML #:nodoc:
18
18
  hash[k] = Conditions.new(v)
19
19
  when :children
20
20
  hash[k] = v = keys_to_symbols(v)
21
- v.each do |k,v2|
22
- case k
21
+ v.each do |key,value|
22
+ case key
23
23
  when :count, :greater_than, :less_than
24
24
  # keys are valid, and require no further processing
25
25
  when :only
26
- v[k] = Conditions.new(v2)
26
+ v[key] = Conditions.new(value)
27
27
  else
28
- raise "illegal key #{k.inspect} => #{v2.inspect}"
28
+ raise "illegal key #{key.inspect} => #{value.inspect}"
29
29
  end
30
30
  end
31
31
  else
@@ -156,7 +156,7 @@ module HTML #:nodoc:
156
156
  end
157
157
 
158
158
  closing = ( scanner.scan(/\//) ? :close : nil )
159
- return Text.new(parent, line, pos, content) unless name = scanner.scan(/[^\s!>\/]+/)
159
+ return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/)
160
160
  name.downcase!
161
161
 
162
162
  unless closing
@@ -1,5 +1,5 @@
1
1
  require 'set'
2
- require 'active_support/core_ext/class/inheritable_attributes'
2
+ require 'active_support/core_ext/class/attribute'
3
3
 
4
4
  module HTML
5
5
  class Sanitizer
@@ -60,7 +60,7 @@ module HTML
60
60
  class WhiteListSanitizer < Sanitizer
61
61
  [:protocol_separator, :uri_attributes, :allowed_attributes, :allowed_tags, :allowed_protocols, :bad_tags,
62
62
  :allowed_css_properties, :allowed_css_keywords, :shorthand_css_properties].each do |attr|
63
- class_inheritable_accessor attr, :instance_writer => false
63
+ class_attribute attr, :instance_writer => false
64
64
  end
65
65
 
66
66
  # A regular expression of the valid characters used to separate protocols like
@@ -170,7 +170,7 @@ module HTML
170
170
 
171
171
  def contains_bad_protocols?(attr_name, value)
172
172
  uri_attributes.include?(attr_name) &&
173
- (value =~ /(^[^\/:]*):|(&#0*58)|(&#x70)|(%|&#37;)3A/ && !allowed_protocols.include?(value.split(protocol_separator).first))
173
+ (value =~ /(^[^\/:]*):|(&#0*58)|(&#x70)|(%|&#37;)3A/ && !allowed_protocols.include?(value.split(protocol_separator).first.downcase))
174
174
  end
175
175
  end
176
176
  end
@@ -128,6 +128,8 @@ module HTML
128
128
  # (no parent element).
129
129
  # * <tt>:empty</tt> -- Match the element only if it has no child elements,
130
130
  # and no text content.
131
+ # * <tt>:content(string)</tt> -- Match the element only if it has <tt>string</tt>
132
+ # as its text content (ignoring leading and trailing whitespace).
131
133
  # * <tt>:only-child</tt> -- Match the element if it is the only child (element)
132
134
  # of its parent element.
133
135
  # * <tt>:only-of-type</tt> -- Match the element if it is the only child (element)
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2010 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2011 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -53,12 +53,14 @@ module ActionDispatch
53
53
  autoload :Flash
54
54
  autoload :Head
55
55
  autoload :ParamsParser
56
+ autoload :Reloader
56
57
  autoload :RemoteIp
57
58
  autoload :Rescue
58
59
  autoload :ShowExceptions
59
60
  autoload :Static
60
61
  end
61
62
 
63
+ autoload :ClosedError, 'action_dispatch/middleware/closed_error'
62
64
  autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
63
65
  autoload :Routing
64
66
 
@@ -85,6 +87,7 @@ module ActionDispatch
85
87
  autoload_under 'testing' do
86
88
  autoload :Assertions
87
89
  autoload :Integration
90
+ autoload :IntegrationTest, 'action_dispatch/testing/integration'
88
91
  autoload :PerformanceTest
89
92
  autoload :TestProcess
90
93
  autoload :TestRequest