Changeset 5513
- Timestamp:
- 11/13/06 19:03:08 (2 years ago)
- Files:
-
- branches/1-2-pre-release/actionpack/CHANGELOG (modified) (1 diff)
- branches/1-2-pre-release/actionpack/lib/action_controller/session_management.rb (modified) (2 diffs)
- branches/1-2-pre-release/actionpack/lib/action_controller/session/drb_store.rb (modified) (1 diff)
- branches/1-2-pre-release/actionpack/lib/action_controller/session/mem_cache_store.rb (modified) (1 diff)
- branches/1-2-pre-release/actionpack/lib/action_controller/test_process.rb (modified) (2 diffs)
- branches/1-2-pre-release/actionpack/test/controller/session_management_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-2-pre-release/actionpack/CHANGELOG
r5500 r5513 1 1 *SVN* 2 3 * Always clear model associations from session. #4795 [sd@notso.net, andylien@gmail.com] 2 4 3 5 * Update to Prototype 1.5.0_rc2. [Sam Stephenson] branches/1-2-pre-release/actionpack/lib/action_controller/session_management.rb
r4699 r5513 121 121 122 122 def process_cleanup_with_session_management_support 123 clear_persistent_model_associations 123 124 process_cleanup_without_session_management_support 124 clear_persistent_model_associations125 125 end 126 126 … … 129 129 # is not a standard way to iterate over session data. 130 130 def clear_persistent_model_associations #:doc: 131 if defined?(@_session) && @_session. instance_variables.include?('@data')132 session_data = @_session. instance_variable_get('@data')131 if defined?(@_session) && @_session.respond_to?(:data) 132 session_data = @_session.data 133 133 134 134 if session_data && session_data.respond_to?(:each_value) branches/1-2-pre-release/actionpack/lib/action_controller/session/drb_store.rb
r4 r5513 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 branches/1-2-pre-release/actionpack/lib/action_controller/session/mem_cache_store.rb
r3465 r5513 94 94 @session_data = {} 95 95 end 96 97 def data 98 @session_data 99 end 96 100 end 97 101 end branches/1-2-pre-release/actionpack/lib/action_controller/test_process.rb
r4935 r5513 39 39 def reset_session 40 40 @session = TestSession.new 41 end 41 end 42 42 43 43 def raw_post … … 276 276 277 277 class TestSession #:nodoc: 278 def initialize(attributes = {}) 278 attr_accessor :session_id 279 280 def initialize(attributes = nil) 281 @session_id = '' 279 282 @attributes = attributes 283 @saved_attributes = nil 284 end 285 286 def data 287 @attributes ||= @saved_attributes || {} 280 288 end 281 289 282 290 def [](key) 283 @attributes[key]291 data[key] 284 292 end 285 293 286 294 def []=(key, value) 287 @attributes[key] = value 288 end 289 290 def session_id 291 "" 292 end 293 294 def update() end 295 def close() end 296 def delete() @attributes = {} end 297 end 298 295 data[key] = value 296 end 297 298 def update 299 @saved_attributes = @attributes 300 end 301 302 def delete 303 @attributes = nil 304 end 305 306 def close 307 update 308 delete 309 end 310 end 311 299 312 # Essentially generates a modified Tempfile object similar to the object 300 313 # you'd get from the standard library CGI module in a multipart branches/1-2-pre-release/actionpack/test/controller/session_management_test.rb
r2230 r5513 44 44 end 45 45 end 46 47 class AssociationCachingTestController < ActionController::Base 48 class ObjectWithAssociationCache 49 def initialize 50 @cached_associations = false 51 end 52 53 def fetch_associations 54 @cached_associations = true 55 end 56 57 def clear_association_cache 58 @cached_associations = false 59 end 60 61 def has_cached_associations? 62 @cached_associations 63 end 64 end 65 66 def show 67 session[:object] = ObjectWithAssociationCache.new 68 session[:object].fetch_associations 69 if session[:object].has_cached_associations? 70 render :text => "has cached associations" 71 else 72 render :text => "does not have cached associations" 73 end 74 end 75 76 def tell 77 if session[:object] 78 if session[:object].has_cached_associations? 79 render :text => "has cached associations" 80 else 81 render :text => "does not have cached associations" 82 end 83 else 84 render :text => "there is no object" 85 end 86 end 87 end 88 46 89 47 90 def setup … … 92 135 end 93 136 end 137 138 def test_process_cleanup_with_session_management_support 139 @controller = AssociationCachingTestController.new 140 get :show 141 assert_equal "has cached associations", @response.body 142 get :tell 143 assert_equal "does not have cached associations", @response.body 144 end 94 145 end