diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-13 18:59:01 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-13 18:59:01 +0000 |
commit | 56e3e2fde5f2b824df37fabc55db34f4ff337ebb (patch) | |
tree | 4f70dfd7cacd82789da6bfda24f5cf9f74609a0e /actionpack/test/controller/session_management_test.rb | |
parent | a303a168ac88d3c5e7a7e71a0c84ea3c2a44f972 (diff) | |
download | rails-56e3e2fde5f2b824df37fabc55db34f4ff337ebb.tar.gz rails-56e3e2fde5f2b824df37fabc55db34f4ff337ebb.tar.bz2 rails-56e3e2fde5f2b824df37fabc55db34f4ff337ebb.zip |
Always clear model associations from session. Closes #4795.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5512 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/session_management_test.rb')
-rw-r--r-- | actionpack/test/controller/session_management_test.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/actionpack/test/controller/session_management_test.rb b/actionpack/test/controller/session_management_test.rb index c611cb8af5..6e100c0c37 100644 --- a/actionpack/test/controller/session_management_test.rb +++ b/actionpack/test/controller/session_management_test.rb @@ -44,6 +44,49 @@ class SessionManagementTest < Test::Unit::TestCase end end + class AssociationCachingTestController < ActionController::Base + class ObjectWithAssociationCache + def initialize + @cached_associations = false + end + + def fetch_associations + @cached_associations = true + end + + def clear_association_cache + @cached_associations = false + end + + def has_cached_associations? + @cached_associations + end + end + + def show + session[:object] = ObjectWithAssociationCache.new + session[:object].fetch_associations + if session[:object].has_cached_associations? + render :text => "has cached associations" + else + render :text => "does not have cached associations" + end + end + + def tell + if session[:object] + if session[:object].has_cached_associations? + render :text => "has cached associations" + else + render :text => "does not have cached associations" + end + else + render :text => "there is no object" + end + end + end + + def setup @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new @@ -91,4 +134,12 @@ class SessionManagementTest < Test::Unit::TestCase assert_equal CGI::Session::ActiveRecordStore, ActionController::Base.session_store end end + + def test_process_cleanup_with_session_management_support + @controller = AssociationCachingTestController.new + get :show + assert_equal "has cached associations", @response.body + get :tell + assert_equal "does not have cached associations", @response.body + end end |