Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5513

Show
Ignore:
Timestamp:
11/13/06 19:03:08 (2 years ago)
Author:
bitsweat
Message:

Merge [5512] from trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-pre-release/actionpack/CHANGELOG

    r5500 r5513  
    11*SVN* 
     2 
     3* Always clear model associations from session.  #4795 [sd@notso.net, andylien@gmail.com] 
    24 
    35* Update to Prototype 1.5.0_rc2. [Sam Stephenson] 
  • branches/1-2-pre-release/actionpack/lib/action_controller/session_management.rb

    r4699 r5513  
    121121       
    122122      def process_cleanup_with_session_management_support 
     123        clear_persistent_model_associations 
    123124        process_cleanup_without_session_management_support 
    124         clear_persistent_model_associations 
    125125      end 
    126126 
     
    129129      # is not a standard way to iterate over session data. 
    130130      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 
    133133 
    134134          if session_data && session_data.respond_to?(:each_value) 
  • branches/1-2-pre-release/actionpack/lib/action_controller/session/drb_store.rb

    r4 r5513  
    2727        @@session_data.delete(@session_id) 
    2828      end 
     29       
     30      def data 
     31        @@session_data[@session_id] 
     32      end 
    2933    end 
    3034  end 
  • branches/1-2-pre-release/actionpack/lib/action_controller/session/mem_cache_store.rb

    r3465 r5513  
    9494          @session_data = {} 
    9595        end 
     96         
     97        def data 
     98          @session_data 
     99        end 
    96100      end 
    97101    end 
  • branches/1-2-pre-release/actionpack/lib/action_controller/test_process.rb

    r4935 r5513  
    3939    def reset_session 
    4040      @session = TestSession.new 
    41     end               
     41    end 
    4242 
    4343    def raw_post 
     
    276276 
    277277  class TestSession #:nodoc: 
    278     def initialize(attributes = {}) 
     278    attr_accessor :session_id 
     279 
     280    def initialize(attributes = nil) 
     281      @session_id = '' 
    279282      @attributes = attributes 
     283      @saved_attributes = nil 
     284    end 
     285 
     286    def data 
     287      @attributes ||= @saved_attributes || {} 
    280288    end 
    281289 
    282290    def [](key) 
    283       @attributes[key] 
     291      data[key] 
    284292    end 
    285293 
    286294    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 
    299312  # Essentially generates a modified Tempfile object similar to the object 
    300313  # 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  
    4444    end 
    4545  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 
    4689 
    4790  def setup 
     
    92135    end 
    93136  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 
    94145end