diff options
Diffstat (limited to 'actionpack/lib')
4 files changed, 34 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/session/drb_store.rb b/actionpack/lib/action_controller/session/drb_store.rb index 8ea23e8fff..4feb2636e7 100644 --- a/actionpack/lib/action_controller/session/drb_store.rb +++ b/actionpack/lib/action_controller/session/drb_store.rb @@ -26,6 +26,10 @@ class CGI #:nodoc:all def delete @@session_data.delete(@session_id) end + + def data + @@session_data[@session_id] + end end end end diff --git a/actionpack/lib/action_controller/session/mem_cache_store.rb b/actionpack/lib/action_controller/session/mem_cache_store.rb index a7076fcd5d..e62c0ef9cd 100644 --- a/actionpack/lib/action_controller/session/mem_cache_store.rb +++ b/actionpack/lib/action_controller/session/mem_cache_store.rb @@ -93,6 +93,10 @@ begin end @session_data = {} end + + def data + @session_data + end end end end diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb index ad1b530d6f..60b0cd5f94 100644 --- a/actionpack/lib/action_controller/session_management.rb +++ b/actionpack/lib/action_controller/session_management.rb @@ -120,16 +120,16 @@ module ActionController #:nodoc: end def process_cleanup_with_session_management_support - process_cleanup_without_session_management_support clear_persistent_model_associations + process_cleanup_without_session_management_support end # Clear cached associations in session data so they don't overflow # the database field. Only applies to ActiveRecordStore since there # is not a standard way to iterate over session data. def clear_persistent_model_associations #:doc: - if defined?(@_session) && @_session.instance_variables.include?('@data') - session_data = @_session.instance_variable_get('@data') + if defined?(@_session) && @_session.respond_to?(:data) + session_data = @_session.data if session_data && session_data.respond_to?(:each_value) session_data.each_value do |obj| diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index bfd2abbb48..f581f6be35 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -38,7 +38,7 @@ module ActionController #:nodoc: def reset_session @session = TestSession.new - end + end def raw_post if raw_post = env['RAW_POST_DATA'] @@ -275,27 +275,40 @@ module ActionController #:nodoc: end class TestSession #:nodoc: - def initialize(attributes = {}) + attr_accessor :session_id + + def initialize(attributes = nil) + @session_id = '' @attributes = attributes + @saved_attributes = nil + end + + def data + @attributes ||= @saved_attributes || {} end def [](key) - @attributes[key] + data[key] end def []=(key, value) - @attributes[key] = value + data[key] = value end - def session_id - "" + def update + @saved_attributes = @attributes end - def update() end - def close() end - def delete() @attributes = {} end + def delete + @attributes = nil + end + + def close + update + delete + end end - + # Essentially generates a modified Tempfile object similar to the object # you'd get from the standard library CGI module in a multipart # request. This means you can use an ActionController::TestUploadedFile |