Permalink
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
2 parents 016ffff + 9e2b4a1 commit ce0e2084107a20a773a587335cfe54bf70ade795 @lifo lifo committed Dec 16, 2008
Showing with 1,411 additions and 1,889 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +6 −9 actionpack/lib/action_controller.rb
  3. +43 −13 actionpack/lib/action_controller/assertions/response_assertions.rb
  4. +1 −1 actionpack/lib/action_controller/assertions/selector_assertions.rb
  5. +5 −10 actionpack/lib/action_controller/base.rb
  6. +0 −1 actionpack/lib/action_controller/cgi_ext.rb
  7. +0 −53 actionpack/lib/action_controller/cgi_ext/session.rb
  8. +1 −1 actionpack/lib/action_controller/cgi_process.rb
  9. +5 −3 actionpack/lib/action_controller/dispatcher.rb
  10. +1 −1 actionpack/lib/action_controller/failsafe.rb
  11. +31 −42 actionpack/lib/action_controller/flash.rb
  12. +3 −5 actionpack/lib/action_controller/integration.rb
  13. +20 −5 actionpack/lib/action_controller/middleware_stack.rb
  14. +8 −0 actionpack/lib/action_controller/mime_type.rb
  15. +12 −127 actionpack/lib/action_controller/rack_process.rb
  16. +1 −1 actionpack/lib/action_controller/rescue.rb
  17. +5 −1 actionpack/lib/action_controller/response.rb
  18. +131 −0 actionpack/lib/action_controller/session/abstract_store.rb
  19. +0 −350 actionpack/lib/action_controller/session/active_record_store.rb
  20. +187 −150 actionpack/lib/action_controller/session/cookie_store.rb
  21. +0 −32 actionpack/lib/action_controller/session/drb_server.rb
  22. +0 −35 actionpack/lib/action_controller/session/drb_store.rb
  23. +36 −83 actionpack/lib/action_controller/session/mem_cache_store.rb
  24. +54 −126 actionpack/lib/action_controller/session_management.rb
  25. +4 −4 actionpack/lib/action_controller/test_process.rb
  26. +4 −0 actionpack/lib/action_view/paths.rb
  27. +0 −5 actionpack/lib/action_view/renderable.rb
  28. +4 −8 actionpack/lib/action_view/template.rb
  29. +24 −1 actionpack/lib/action_view/template_handlers.rb
  30. +24 −1 actionpack/lib/action_view/test_case.rb
  31. +2 −0 actionpack/test/abstract_unit.rb
  32. +95 −107 actionpack/test/activerecord/active_record_store_test.rb
  33. +3 −3 actionpack/test/controller/action_pack_assertions_test.rb
  34. +0 −2 actionpack/test/controller/integration_test.rb
  35. +0 −2 actionpack/test/controller/integration_upload_test.rb
  36. +8 −0 actionpack/test/controller/mime_type_test.rb
  37. +2 −24 actionpack/test/controller/rack_test.rb
  38. +16 −0 actionpack/test/controller/render_test.rb
  39. +1 −0 actionpack/test/controller/send_file_test.rb
  40. +98 −250 actionpack/test/controller/session/cookie_store_test.rb
  41. +55 −152 actionpack/test/controller/session/mem_cache_store_test.rb
  42. +84 −84 actionpack/test/controller/session_fixation_test.rb
  43. +0 −178 actionpack/test/controller/session_management_test.rb
  44. +0 −2 actionpack/test/controller/webservice_test.rb
  45. +8 −0 actionpack/test/view/test_case_test.rb
  46. +1 −0 activerecord/lib/active_record.rb
  47. +319 −0 activerecord/lib/active_record/session_store.rb
  48. +1 −0 activerecord/test/cases/helper.rb
  49. +1 −1 activesupport/lib/active_support/dependencies.rb
  50. +1 −1 activesupport/lib/active_support/deprecation.rb
  51. +39 −3 activesupport/lib/active_support/ordered_hash.rb
  52. +58 −1 activesupport/test/ordered_hash_test.rb
  53. +2 −10 railties/lib/initializer.rb
  54. +3 −0 railties/lib/rails/backtrace_cleaner.rb
  55. +1 −1 railties/lib/tasks/databases.rake
  56. +1 −0 railties/test/console_app_test.rb
View
@@ -1,5 +1,7 @@
*2.3.0 [Edge]*
+* Fixed that send_file shouldn't set an etag #1578 [Hongli Lai]
+
* Allow users to opt out of the spoofing checks in Request#remote_ip. Useful for sites whose traffic regularly triggers false positives. [Darren Boyd]
* Deprecated formatted_polymorphic_url. [Jeremy Kemper]
@@ -89,18 +89,15 @@ module Http
autoload :Headers, 'action_controller/headers'
end
- # DEPRECATE: Remove CGI support
- autoload :CgiRequest, 'action_controller/cgi_process'
- autoload :CGIHandler, 'action_controller/cgi_process'
-end
-
-class CGI
- class Session
- autoload :ActiveRecordStore, 'action_controller/session/active_record_store'
+ module Session
+ autoload :AbstractStore, 'action_controller/session/abstract_store'
autoload :CookieStore, 'action_controller/session/cookie_store'
- autoload :DRbStore, 'action_controller/session/drb_store'
autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
end
+
+ # DEPRECATE: Remove CGI support
+ autoload :CgiRequest, 'action_controller/cgi_process'
+ autoload :CGIHandler, 'action_controller/cgi_process'
end
autoload :Mime, 'action_controller/mime_type'
@@ -16,7 +16,7 @@ module ResponseAssertions
# ==== Examples
#
# # assert that the response was a redirection
- # assert_response :redirect
+ # assert_response :redirect
#
# # assert that the response code was status code 401 (unauthorized)
# assert_response 401
@@ -41,7 +41,7 @@ def assert_response(type, message = nil)
end
end
- # Assert that the redirection options passed in match those of the redirect called in the latest action.
+ # Assert that the redirection options passed in match those of the redirect called in the latest action.
# This match can be partial, such that assert_redirected_to(:controller => "weblog") will also
# match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on.
#
@@ -60,12 +60,12 @@ def assert_redirected_to(options = {}, message=nil)
clean_backtrace do
assert_response(:redirect, message)
return true if options == @response.redirected_to
-
+
# Support partial arguments for hash redirections
if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
end
-
+
redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
options_after_normalisation = normalize_argument_to_redirection(options)
@@ -75,29 +75,59 @@ def assert_redirected_to(options = {}, message=nil)
end
end
- # Asserts that the request was rendered with the appropriate template file.
+ # Asserts that the request was rendered with the appropriate template file or partials
#
# ==== Examples
#
# # assert that the "new" view template was rendered
# assert_template "new"
#
- def assert_template(expected = nil, message=nil)
+ # # assert that the "_customer" partial was rendered twice
+ # assert_template :partial => '_customer', :count => 2
+ #
+ # # assert that no partials were rendered
+ # assert_template :partial => false
+ #
+ def assert_template(options = {}, message = nil)
clean_backtrace do
- rendered = @response.rendered_template.to_s
- msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
- assert_block(msg) do
- if expected.nil?
- @response.rendered_template.blank?
+ case options
+ when NilClass, String
+ rendered = @response.rendered[:template].to_s
+ msg = build_message(message,
+ "expecting <?> but rendering with <?>",
+ options, rendered)
+ assert_block(msg) do
+ if options.nil?
+ @response.rendered[:template].blank?
+ else
+ rendered.to_s.match(options)
+ end
+ end
+ when Hash
+ if expected_partial = options[:partial]
+ partials = @response.rendered[:partials]
+ if expected_count = options[:count]
+ found = partials.detect { |p, _| p.to_s.match(expected_partial) }
+ actual_count = found.nil? ? 0 : found.second
+ msg = build_message(message,
+ "expecting ? to be rendered ? time(s) but rendered ? time(s)",
+ expected_partial, expected_count, actual_count)
+ assert(actual_count == expected_count.to_i, msg)
+ else
+ msg = build_message(message,
+ "expecting partial <?> but action rendered <?>",
+ options[:partial], partials.keys)
+ assert(partials.keys.any? { |p| p.to_s.match(expected_partial) }, msg)
+ end
else
- rendered.to_s.match(expected)
+ assert @response.rendered[:partials].empty?,
+ "Expected no partials to be rendered"
end
end
end
end
private
-
# Proxy to to_param if the object will respond to it.
def parameterize(value)
value.respond_to?(:to_param) ? value.to_param : value
@@ -587,7 +587,7 @@ def assert_select_email(&block)
def response_from_page_or_rjs()
content_type = @response.content_type
- if content_type && content_type =~ /text\/javascript/
+ if content_type && Mime::JS =~ content_type
body = @response.body.dup
root = HTML::Node.new(nil)
@@ -164,8 +164,8 @@ class UnknownHttpMethod < ActionControllerError #:nodoc:
#
# Other options for session storage are:
#
- # * ActiveRecordStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
- # unlike CookieStore, hides your session contents from the user. To use ActiveRecordStore, set
+ # * ActiveRecord::SessionStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
+ # unlike CookieStore, hides your session contents from the user. To use ActiveRecord::SessionStore, set
#
# config.action_controller.session_store = :active_record_store
#
@@ -1160,6 +1160,9 @@ def expires_now #:doc:
def reset_session #:doc:
request.reset_session
@_session = request.session
+ #http://rails.lighthouseapp.com/projects/8994/tickets/1558-memory-problem-on-reset_session-in-around_filter#ticket-1558-1
+ #MRI appears to have a GC related memory leak to do with the finalizer that is defined on CGI::Session
+ ObjectSpace.undefine_finalizer(@_session)
response.session = @_session
end
@@ -1213,7 +1216,6 @@ def initialize_current_url
def log_processing
if logger && logger.info?
log_processing_for_request_id
- log_processing_for_session_id
log_processing_for_parameters
end
end
@@ -1226,13 +1228,6 @@ def log_processing_for_request_id
logger.info(request_id)
end
- def log_processing_for_session_id
- if @_session && @_session.respond_to?(:session_id) && @_session.respond_to?(:dbman) &&
- !@_session.dbman.is_a?(CGI::Session::CookieStore)
- logger.info " Session ID: #{@_session.session_id}"
- end
- end
-
def log_processing_for_parameters
parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup
parameters = parameters.except!(:controller, :action, :format, :_method)
@@ -1,7 +1,6 @@
require 'action_controller/cgi_ext/stdinput'
require 'action_controller/cgi_ext/query_extension'
require 'action_controller/cgi_ext/cookie'
-require 'action_controller/cgi_ext/session'
class CGI #:nodoc:
include ActionController::CgiExt::Stdinput
@@ -1,53 +0,0 @@
-require 'digest/md5'
-require 'cgi/session'
-require 'cgi/session/pstore'
-
-class CGI #:nodoc:
- # * Expose the CGI instance to session stores.
- # * Don't require 'digest/md5' whenever a new session id is generated.
- class Session #:nodoc:
- def self.generate_unique_id(constant = nil)
- ActiveSupport::SecureRandom.hex(16)
- end
-
- # Make the CGI instance available to session stores.
- attr_reader :cgi
- attr_reader :dbman
- alias_method :initialize_without_cgi_reader, :initialize
- def initialize(cgi, options = {})
- @cgi = cgi
- initialize_without_cgi_reader(cgi, options)
- end
-
- private
- # Create a new session id.
- def create_new_id
- @new_session = true
- self.class.generate_unique_id
- end
-
- # * Don't require 'digest/md5' whenever a new session is started.
- class PStore #:nodoc:
- def initialize(session, option={})
- dir = option['tmpdir'] || Dir::tmpdir
- prefix = option['prefix'] || ''
- id = session.session_id
- md5 = Digest::MD5.hexdigest(id)[0,16]
- path = dir+"/"+prefix+md5
- path.untaint
- if File::exist?(path)
- @hash = nil
- else
- unless session.new_session
- raise CGI::Session::NoSession, "uninitialized session"
- end
- @hash = {}
- end
- @p = ::PStore.new(path)
- @p.transaction do |p|
- File.chmod(0600, p.path)
- end
- end
- end
- end
-end
@@ -61,7 +61,7 @@ def self.dispatch_cgi(app, cgi, out = $stdout)
class CgiRequest #:nodoc:
DEFAULT_SESSION_OPTIONS = {
- :database_manager => CGI::Session::CookieStore,
+ :database_manager => nil,
:prefix => "ruby_sess.",
:session_path => "/",
:session_key => "_session_id",
@@ -45,8 +45,10 @@ def to_prepare(identifier = nil, &block)
end
cattr_accessor :middleware
- self.middleware = MiddlewareStack.new
- self.middleware.use "ActionController::Failsafe"
+ self.middleware = MiddlewareStack.new do |middleware|
+ middleware.use "ActionController::Failsafe"
+ middleware.use "ActionController::SessionManagement::Middleware"
+ end
include ActiveSupport::Callbacks
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
@@ -89,7 +91,7 @@ def call(env)
def _call(env)
@request = RackRequest.new(env)
- @response = RackResponse.new(@request)
+ @response = RackResponse.new
dispatch
end
@@ -42,7 +42,7 @@ def log_failsafe_exception(exception)
end
def failsafe_logger
- if defined? Rails && Rails.logger
+ if defined?(Rails) && Rails.logger
Rails.logger
else
Logger.new($stderr)
Oops, something went wrong.

0 comments on commit ce0e208

Please sign in to comment.