actionpack 2.3.2 → 2.3.3

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 (117) hide show
  1. data/CHANGELOG +5 -0
  2. data/Rakefile +10 -9
  3. data/lib/action_controller.rb +2 -7
  4. data/lib/action_controller/assertions/response_assertions.rb +11 -3
  5. data/lib/action_controller/base.rb +7 -2
  6. data/lib/action_controller/caching.rb +1 -1
  7. data/lib/action_controller/caching/actions.rb +9 -1
  8. data/lib/action_controller/caching/sweeper.rb +45 -0
  9. data/lib/action_controller/caching/sweeping.rb +0 -42
  10. data/lib/action_controller/failsafe.rb +40 -6
  11. data/lib/action_controller/flash.rb +11 -3
  12. data/lib/action_controller/http_authentication.rb +5 -2
  13. data/lib/action_controller/integration.rb +5 -12
  14. data/lib/action_controller/middlewares.rb +0 -1
  15. data/lib/action_controller/reloader.rb +34 -3
  16. data/lib/action_controller/request.rb +6 -2
  17. data/lib/action_controller/response.rb +2 -2
  18. data/lib/action_controller/routing/route_set.rb +2 -1
  19. data/lib/action_controller/streaming.rb +1 -1
  20. data/lib/action_controller/test_process.rb +9 -1
  21. data/lib/action_pack/version.rb +1 -1
  22. data/lib/action_view/helpers.rb +1 -1
  23. data/lib/action_view/helpers/asset_tag_helper.rb +21 -9
  24. data/lib/action_view/helpers/date_helper.rb +2 -2
  25. data/lib/action_view/helpers/form_helper.rb +25 -12
  26. data/lib/action_view/helpers/form_options_helper.rb +2 -0
  27. data/lib/action_view/helpers/form_tag_helper.rb +10 -4
  28. data/lib/action_view/helpers/number_helper.rb +1 -1
  29. data/lib/action_view/helpers/prototype_helper.rb +7 -7
  30. data/lib/action_view/helpers/scriptaculous_helper.rb +5 -5
  31. data/lib/action_view/helpers/text_helper.rb +3 -3
  32. data/lib/action_view/helpers/url_helper.rb +1 -1
  33. data/lib/action_view/paths.rb +1 -1
  34. data/lib/action_view/template.rb +22 -33
  35. data/test/abstract_unit.rb +1 -1
  36. data/test/activerecord/active_record_store_test.rb +3 -3
  37. data/test/controller/action_pack_assertions_test.rb +27 -0
  38. data/test/controller/caching_test.rb +39 -0
  39. data/test/controller/cookie_test.rb +10 -0
  40. data/test/controller/dispatcher_test.rb +9 -7
  41. data/test/controller/failsafe_test.rb +60 -0
  42. data/test/controller/filter_params_test.rb +2 -1
  43. data/test/controller/flash_test.rb +6 -1
  44. data/test/controller/http_digest_authentication_test.rb +34 -3
  45. data/test/controller/integration_test.rb +31 -3
  46. data/test/controller/redirect_test.rb +4 -1
  47. data/test/controller/reloader_test.rb +97 -0
  48. data/test/controller/render_test.rb +19 -9
  49. data/test/controller/request/multipart_params_parsing_test.rb +1 -62
  50. data/test/controller/request/test_request_test.rb +35 -0
  51. data/test/controller/request/url_encoded_params_parsing_test.rb +0 -38
  52. data/test/controller/request_test.rb +218 -230
  53. data/test/controller/resources_test.rb +8 -0
  54. data/test/controller/routing_test.rb +21 -0
  55. data/test/controller/send_file_test.rb +1 -1
  56. data/test/controller/session/cookie_store_test.rb +9 -32
  57. data/test/controller/test_test.rb +8 -0
  58. data/test/fixtures/failsafe/500.html +1 -0
  59. data/test/template/active_record_helper_test.rb +1 -1
  60. data/test/template/asset_tag_helper_test.rb +46 -0
  61. data/test/template/form_helper_test.rb +117 -6
  62. data/test/template/form_options_helper_test.rb +22 -0
  63. data/test/template/form_tag_helper_test.rb +23 -6
  64. data/test/template/prototype_helper_test.rb +11 -11
  65. data/test/template/template_test.rb +32 -0
  66. metadata +20 -63
  67. data/lib/action_controller/rewindable_input.rb +0 -28
  68. data/lib/action_controller/vendor/rack-1.0/rack.rb +0 -89
  69. data/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +0 -22
  70. data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +0 -37
  71. data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +0 -37
  72. data/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +0 -58
  73. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +0 -124
  74. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +0 -51
  75. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +0 -55
  76. data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +0 -40
  77. data/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +0 -480
  78. data/lib/action_controller/vendor/rack-1.0/rack/builder.rb +0 -63
  79. data/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +0 -36
  80. data/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +0 -49
  81. data/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +0 -61
  82. data/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +0 -45
  83. data/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +0 -29
  84. data/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +0 -23
  85. data/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +0 -85
  86. data/lib/action_controller/vendor/rack-1.0/rack/directory.rb +0 -153
  87. data/lib/action_controller/vendor/rack-1.0/rack/file.rb +0 -88
  88. data/lib/action_controller/vendor/rack-1.0/rack/handler.rb +0 -48
  89. data/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +0 -61
  90. data/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +0 -8
  91. data/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +0 -89
  92. data/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +0 -55
  93. data/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +0 -84
  94. data/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +0 -59
  95. data/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +0 -8
  96. data/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +0 -18
  97. data/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +0 -67
  98. data/lib/action_controller/vendor/rack-1.0/rack/head.rb +0 -19
  99. data/lib/action_controller/vendor/rack-1.0/rack/lint.rb +0 -462
  100. data/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +0 -65
  101. data/lib/action_controller/vendor/rack-1.0/rack/lock.rb +0 -16
  102. data/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +0 -27
  103. data/lib/action_controller/vendor/rack-1.0/rack/mime.rb +0 -204
  104. data/lib/action_controller/vendor/rack-1.0/rack/mock.rb +0 -160
  105. data/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +0 -57
  106. data/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +0 -64
  107. data/lib/action_controller/vendor/rack-1.0/rack/request.rb +0 -241
  108. data/lib/action_controller/vendor/rack-1.0/rack/response.rb +0 -179
  109. data/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +0 -142
  110. data/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +0 -91
  111. data/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +0 -109
  112. data/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +0 -100
  113. data/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +0 -349
  114. data/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +0 -106
  115. data/lib/action_controller/vendor/rack-1.0/rack/static.rb +0 -38
  116. data/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +0 -55
  117. data/lib/action_controller/vendor/rack-1.0/rack/utils.rb +0 -392
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *2.3.3 (July 20, 2009)*
2
+
3
+ * Fixed that TestResponse.cookies was returning cookies unescaped #1867 [Doug McInnes]
4
+
5
+
1
6
  *2.3.2 [Final] (March 15, 2009)*
2
7
 
3
8
  * Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #<Post:0x23150b8>") [DHH]
data/Rakefile CHANGED
@@ -4,7 +4,6 @@ require 'rake/testtask'
4
4
  require 'rake/rdoctask'
5
5
  require 'rake/packagetask'
6
6
  require 'rake/gempackagetask'
7
- require 'rake/contrib/sshpublisher'
8
7
  require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
9
8
 
10
9
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
@@ -80,7 +79,8 @@ spec = Gem::Specification.new do |s|
80
79
  s.has_rdoc = true
81
80
  s.requirements << 'none'
82
81
 
83
- s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD)
82
+ s.add_dependency('activesupport', '= 2.3.3' + PKG_BUILD)
83
+ s.add_dependency('rack', '~> 1.0.0')
84
84
 
85
85
  s.require_path = 'lib'
86
86
  s.autorequire = 'action_controller'
@@ -136,23 +136,24 @@ task :update_js => [ :update_scriptaculous ]
136
136
 
137
137
  desc "Publish the API documentation"
138
138
  task :pgem => [:package] do
139
+ require 'rake/contrib/sshpublisher'
139
140
  Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
140
141
  `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
141
142
  end
142
143
 
143
144
  desc "Publish the API documentation"
144
145
  task :pdoc => [:rdoc] do
146
+ require 'rake/contrib/sshpublisher'
145
147
  Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ap", "doc").upload
146
148
  end
147
149
 
148
150
  desc "Publish the release files to RubyForge."
149
151
  task :release => [ :package ] do
150
- require 'rubyforge'
151
- require 'rake/contrib/rubyforgepublisher'
152
+ `rubyforge login`
152
153
 
153
- packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
154
-
155
- rubyforge = RubyForge.new
156
- rubyforge.login
157
- rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
154
+ for ext in %w( gem tgz zip )
155
+ release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
156
+ puts release_command
157
+ system(release_command)
158
+ end
158
159
  end
@@ -31,12 +31,8 @@ rescue LoadError
31
31
  end
32
32
  end
33
33
 
34
- begin
35
- gem 'rack', '~> 1.0.0'
36
- require 'rack'
37
- rescue Gem::LoadError
38
- require 'action_controller/vendor/rack-1.0/rack'
39
- end
34
+ gem 'rack', '~> 1.0.0'
35
+ require 'rack'
40
36
 
41
37
  module ActionController
42
38
  # TODO: Review explicit to see if they will automatically be handled by
@@ -45,7 +41,6 @@ module ActionController
45
41
  [Base, CGIHandler, CgiRequest, Request, Response, Http::Headers, UrlRewriter, UrlWriter]
46
42
  end
47
43
 
48
- autoload :AbstractRequest, 'action_controller/request'
49
44
  autoload :Base, 'action_controller/base'
50
45
  autoload :Benchmarking, 'action_controller/benchmarking'
51
46
  autoload :Caching, 'action_controller/caching'
@@ -63,7 +63,10 @@ module ActionController
63
63
 
64
64
  # Support partial arguments for hash redirections
65
65
  if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
66
- return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
66
+ if options.all? {|(key, value)| @response.redirected_to[key] == value}
67
+ ::ActiveSupport::Deprecation.warn("Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead", caller)
68
+ return true
69
+ end
67
70
  end
68
71
 
69
72
  redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
@@ -82,6 +85,9 @@ module ActionController
82
85
  # # assert that the "new" view template was rendered
83
86
  # assert_template "new"
84
87
  #
88
+ # # assert that the "new" view template was rendered with Symbol
89
+ # assert_template :new
90
+ #
85
91
  # # assert that the "_customer" partial was rendered twice
86
92
  # assert_template :partial => '_customer', :count => 2
87
93
  #
@@ -91,7 +97,7 @@ module ActionController
91
97
  def assert_template(options = {}, message = nil)
92
98
  clean_backtrace do
93
99
  case options
94
- when NilClass, String
100
+ when NilClass, String, Symbol
95
101
  rendered = @response.rendered[:template].to_s
96
102
  msg = build_message(message,
97
103
  "expecting <?> but rendering with <?>",
@@ -100,7 +106,7 @@ module ActionController
100
106
  if options.nil?
101
107
  @response.rendered[:template].blank?
102
108
  else
103
- rendered.to_s.match(options)
109
+ rendered.to_s.match(options.to_s)
104
110
  end
105
111
  end
106
112
  when Hash
@@ -123,6 +129,8 @@ module ActionController
123
129
  assert @response.rendered[:partials].empty?,
124
130
  "Expected no partials to be rendered"
125
131
  end
132
+ else
133
+ raise ArgumentError
126
134
  end
127
135
  end
128
136
  end
@@ -491,6 +491,10 @@ module ActionController #:nodoc:
491
491
  filtered_parameters[key] = '[FILTERED]'
492
492
  elsif value.is_a?(Hash)
493
493
  filtered_parameters[key] = filter_parameters(value)
494
+ elsif value.is_a?(Array)
495
+ filtered_parameters[key] = value.collect do |item|
496
+ filter_parameters(item)
497
+ end
494
498
  elsif block_given?
495
499
  key = key.dup
496
500
  value = value.dup if value
@@ -950,8 +954,9 @@ module ActionController #:nodoc:
950
954
  response.content_type ||= Mime::JS
951
955
  render_for_text(js, options[:status])
952
956
 
953
- elsif json = options[:json]
954
- json = json.to_json unless json.is_a?(String)
957
+ elsif options.include?(:json)
958
+ json = options[:json]
959
+ json = ActiveSupport::JSON.encode(json) unless json.is_a?(String)
955
960
  json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
956
961
  response.content_type ||= Mime::JSON
957
962
  render_for_text(json, options[:status])
@@ -27,7 +27,7 @@ module ActionController #:nodoc:
27
27
  autoload :Actions, 'action_controller/caching/actions'
28
28
  autoload :Fragments, 'action_controller/caching/fragments'
29
29
  autoload :Pages, 'action_controller/caching/pages'
30
- autoload :Sweeper, 'action_controller/caching/sweeping'
30
+ autoload :Sweeper, 'action_controller/caching/sweeper'
31
31
  autoload :Sweeping, 'action_controller/caching/sweeping'
32
32
 
33
33
  def self.included(base) #:nodoc:
@@ -61,7 +61,9 @@ module ActionController #:nodoc:
61
61
  filter_options = { :only => actions, :if => options.delete(:if), :unless => options.delete(:unless) }
62
62
 
63
63
  cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options)
64
- around_filter(cache_filter, filter_options)
64
+ around_filter(filter_options) do |controller, action|
65
+ cache_filter.filter(controller, action)
66
+ end
65
67
  end
66
68
  end
67
69
 
@@ -83,6 +85,12 @@ module ActionController #:nodoc:
83
85
  @options = options
84
86
  end
85
87
 
88
+ def filter(controller, action)
89
+ should_continue = before(controller)
90
+ action.call if should_continue
91
+ after(controller)
92
+ end
93
+
86
94
  def before(controller)
87
95
  cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path)))
88
96
  if cache = controller.read_fragment(cache_path.path, @options[:store_options])
@@ -0,0 +1,45 @@
1
+ require 'active_record'
2
+
3
+ module ActionController #:nodoc:
4
+ module Caching
5
+ class Sweeper < ActiveRecord::Observer #:nodoc:
6
+ attr_accessor :controller
7
+
8
+ def before(controller)
9
+ self.controller = controller
10
+ callback(:before) if controller.perform_caching
11
+ end
12
+
13
+ def after(controller)
14
+ callback(:after) if controller.perform_caching
15
+ # Clean up, so that the controller can be collected after this request
16
+ self.controller = nil
17
+ end
18
+
19
+ protected
20
+ # gets the action cache path for the given options.
21
+ def action_path_for(options)
22
+ ActionController::Caching::Actions::ActionCachePath.path_for(controller, options)
23
+ end
24
+
25
+ # Retrieve instance variables set in the controller.
26
+ def assigns(key)
27
+ controller.instance_variable_get("@#{key}")
28
+ end
29
+
30
+ private
31
+ def callback(timing)
32
+ controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
33
+ action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
34
+
35
+ __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
36
+ __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
37
+ end
38
+
39
+ def method_missing(method, *arguments, &block)
40
+ return if @controller.nil?
41
+ @controller.__send__(method, *arguments, &block)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -51,47 +51,5 @@ module ActionController #:nodoc:
51
51
  end
52
52
  end
53
53
  end
54
-
55
- if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)
56
- class Sweeper < ActiveRecord::Observer #:nodoc:
57
- attr_accessor :controller
58
-
59
- def before(controller)
60
- self.controller = controller
61
- callback(:before) if controller.perform_caching
62
- end
63
-
64
- def after(controller)
65
- callback(:after) if controller.perform_caching
66
- # Clean up, so that the controller can be collected after this request
67
- self.controller = nil
68
- end
69
-
70
- protected
71
- # gets the action cache path for the given options.
72
- def action_path_for(options)
73
- ActionController::Caching::Actions::ActionCachePath.path_for(controller, options)
74
- end
75
-
76
- # Retrieve instance variables set in the controller.
77
- def assigns(key)
78
- controller.instance_variable_get("@#{key}")
79
- end
80
-
81
- private
82
- def callback(timing)
83
- controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
84
- action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
85
-
86
- __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
87
- __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
88
- end
89
-
90
- def method_missing(method, *arguments, &block)
91
- return if @controller.nil?
92
- @controller.__send__(method, *arguments, &block)
93
- end
94
- end
95
- end
96
54
  end
97
55
  end
@@ -1,4 +1,19 @@
1
+ require 'erb'
2
+
1
3
  module ActionController
4
+ # The Failsafe middleware is usually the top-most middleware in the Rack
5
+ # middleware chain. It returns the underlying middleware's response, but if
6
+ # the underlying middle raises an exception then Failsafe will log the
7
+ # exception into the Rails log file, and will attempt to return an error
8
+ # message response.
9
+ #
10
+ # Failsafe is a last resort for logging errors and for telling the HTTP
11
+ # client that something went wrong. Do not confuse this with the
12
+ # ActionController::Rescue module, which is responsible for catching
13
+ # exceptions at deeper levels. Unlike Failsafe, which is as simple as
14
+ # possible, Rescue provides features that allow developers to hook into
15
+ # the error handling logic, and can customize the error message response
16
+ # based on the HTTP client's IP.
2
17
  class Failsafe
3
18
  cattr_accessor :error_file_path
4
19
  self.error_file_path = Rails.public_path if defined?(Rails.public_path)
@@ -11,7 +26,7 @@ module ActionController
11
26
  @app.call(env)
12
27
  rescue Exception => exception
13
28
  # Reraise exception in test environment
14
- if env["rack.test"]
29
+ if defined?(Rails) && Rails.env.test?
15
30
  raise exception
16
31
  else
17
32
  failsafe_response(exception)
@@ -21,18 +36,37 @@ module ActionController
21
36
  private
22
37
  def failsafe_response(exception)
23
38
  log_failsafe_exception(exception)
24
- [500, {'Content-Type' => 'text/html'}, failsafe_response_body]
39
+ [500, {'Content-Type' => 'text/html'}, [failsafe_response_body]]
25
40
  rescue Exception => failsafe_error # Logger or IO errors
26
41
  $stderr.puts "Error during failsafe response: #{failsafe_error}"
27
42
  end
28
43
 
29
44
  def failsafe_response_body
30
- error_path = "#{self.class.error_file_path}/500.html"
31
- if File.exist?(error_path)
32
- File.read(error_path)
45
+ error_template_path = "#{self.class.error_file_path}/500.html"
46
+ if File.exist?(error_template_path)
47
+ begin
48
+ result = render_template(error_template_path)
49
+ rescue Exception
50
+ result = nil
51
+ end
33
52
  else
34
- "<html><body><h1>500 Internal Server Error</h1></body></html>"
53
+ result = nil
54
+ end
55
+ if result.nil?
56
+ result = "<html><body><h1>500 Internal Server Error</h1>" <<
57
+ "If you are the administrator of this website, then please read this web " <<
58
+ "application's log file to find out what went wrong.</body></html>"
35
59
  end
60
+ result
61
+ end
62
+
63
+ # The default 500.html uses the h() method.
64
+ def h(text) # :nodoc:
65
+ ERB::Util.h(text)
66
+ end
67
+
68
+ def render_template(filename)
69
+ ERB.new(File.read(filename)).result(binding)
36
70
  end
37
71
 
38
72
  def log_failsafe_exception(exception)
@@ -120,6 +120,11 @@ module ActionController #:nodoc:
120
120
  (@used.keys - keys).each{ |k| @used.delete(k) }
121
121
  end
122
122
 
123
+ def store(session, key = "flash")
124
+ return if self.empty?
125
+ session[key] = self
126
+ end
127
+
123
128
  private
124
129
  # Used internally by the <tt>keep</tt> and <tt>discard</tt> methods
125
130
  # use() # marks the entire flash as used
@@ -139,7 +144,10 @@ module ActionController #:nodoc:
139
144
  protected
140
145
  def perform_action_with_flash
141
146
  perform_action_without_flash
142
- remove_instance_variable(:@_flash) if defined? @_flash
147
+ if defined? @_flash
148
+ @_flash.store(session)
149
+ remove_instance_variable(:@_flash)
150
+ end
143
151
  end
144
152
 
145
153
  def reset_session_with_flash
@@ -151,8 +159,8 @@ module ActionController #:nodoc:
151
159
  # read a notice you put there or <tt>flash["notice"] = "hello"</tt>
152
160
  # to put a new one.
153
161
  def flash #:doc:
154
- unless defined? @_flash
155
- @_flash = session["flash"] ||= FlashHash.new
162
+ if !defined?(@_flash)
163
+ @_flash = session["flash"] || FlashHash.new
156
164
  @_flash.sweep
157
165
  end
158
166
 
@@ -183,7 +183,7 @@ module ActionController
183
183
  request.env['REDIRECT_X_HTTP_AUTHORIZATION']
184
184
  end
185
185
 
186
- # Raises error unless the request credentials response value matches the expected value.
186
+ # Returns false unless the request credentials response value matches the expected value.
187
187
  # First try the password as a ha1 digest password. If this fails, then try it as a plain
188
188
  # text password.
189
189
  def validate_digest_response(request, realm, &password_procedure)
@@ -192,9 +192,12 @@ module ActionController
192
192
 
193
193
  if valid_nonce && realm == credentials[:realm] && opaque == credentials[:opaque]
194
194
  password = password_procedure.call(credentials[:username])
195
+ return false unless password
196
+
197
+ method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD']
195
198
 
196
199
  [true, false].any? do |password_is_ha1|
197
- expected = expected_response(request.env['REQUEST_METHOD'], request.env['REQUEST_URI'], credentials, password, password_is_ha1)
200
+ expected = expected_response(method, request.env['REQUEST_URI'], credentials, password, password_is_ha1)
198
201
  expected == credentials[:response]
199
202
  end
200
203
  end
@@ -5,7 +5,7 @@ require 'active_support/test_case'
5
5
  module ActionController
6
6
  module Integration #:nodoc:
7
7
  # An integration Session instance represents a set of requests and responses
8
- # performed sequentially by some virtual user. Becase you can instantiate
8
+ # performed sequentially by some virtual user. Because you can instantiate
9
9
  # multiple sessions and run them side-by-side, you can also mimic (to some
10
10
  # limited extent) multiple simultaneous users interacting with your system.
11
11
  #
@@ -292,9 +292,7 @@ module ActionController
292
292
  "rack.errors" => StringIO.new,
293
293
  "rack.multithread" => true,
294
294
  "rack.multiprocess" => true,
295
- "rack.run_once" => false,
296
-
297
- "rack.test" => true
295
+ "rack.run_once" => false
298
296
  )
299
297
 
300
298
  (headers || {}).each do |key, value|
@@ -311,12 +309,7 @@ module ActionController
311
309
 
312
310
  ActionController::Base.clear_last_instantiation!
313
311
 
314
- app = @application
315
- # Rack::Lint doesn't accept String headers or bodies in Ruby 1.9
316
- unless RUBY_VERSION >= '1.9.0' && Rack.release <= '0.9.0'
317
- app = Rack::Lint.new(app)
318
- end
319
-
312
+ app = Rack::Lint.new(@application)
320
313
  status, headers, body = app.call(env)
321
314
  @request_count += 1
322
315
 
@@ -333,7 +326,7 @@ module ActionController
333
326
  end
334
327
 
335
328
  @body = ""
336
- if body.is_a?(String)
329
+ if body.respond_to?(:to_str)
337
330
  @body << body
338
331
  else
339
332
  body.each { |part| @body << part }
@@ -416,7 +409,7 @@ module ActionController
416
409
  def multipart_requestify(params, first=true)
417
410
  returning Hash.new do |p|
418
411
  params.each do |key, value|
419
- k = first ? CGI.escape(key.to_s) : "[#{CGI.escape(key.to_s)}]"
412
+ k = first ? key.to_s : "[#{key.to_s}]"
420
413
  if Hash === value
421
414
  multipart_requestify(value, false).each do |subkey, subvalue|
422
415
  p[k + subkey] = subvalue