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

Changeset 2696

Show
Ignore:
Timestamp:
10/20/05 21:59:48 (3 years ago)
Author:
bitsweat
Message:

Expose the session model backing CGI::Session

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r2688 r2696  
    11*SVN* 
     2 
     3* Expose the session model backing CGI::Session 
    24 
    35* Abbreviate RAILS_ROOT in traces 
  • trunk/actionpack/lib/action_controller/base.rb

    r2649 r2696  
    55require 'action_controller/url_rewriter' 
    66require 'drb' 
     7require 'set' 
    78 
    89module ActionController #:nodoc: 
     
    847848 
    848849      def self.action_methods 
    849         #puts "action method: #{public_instance_methods.inspect}" 
    850         @action_methods ||= (public_instance_methods - hidden_actions).inject({}) { |h, k| h[k] = true; h } 
     850        @action_methods ||= Set.new(public_instance_methods - hidden_actions) 
    851851      end 
    852852 
  • trunk/actionpack/lib/action_controller/session/active_record_store.rb

    r2663 r2696  
    66class CGI 
    77  class Session 
     8    # Return this session's underlying Session model. Useful for the DB-backed session stores. 
     9    def model 
     10      @dbman.model rescue nil 
     11    end 
     12 
     13    # Proxy missing methods to the underlying Session model. 
     14    def method_missing(method, *args, &block) 
     15      if model then model.send(method, *args, &block) else super end 
     16    end 
     17 
    818    # A session store backed by an Active Record class. 
    919    # 
     
    278288      end 
    279289 
     290      # Access the underlying session model. 
     291      def model 
     292        @session 
     293      end 
     294 
    280295      # Restore session state.  The session model handles unmarshaling. 
    281296      def restore 
  • trunk/actionpack/test/controller/active_record_store_test.rb

    r2612 r2696  
    5454    end 
    5555  end 
    56  
    5756end 
    5857 
     
    7473  end 
    7574 
     75  def test_model_attribute 
     76    assert_kind_of CGI::Session::ActiveRecordStore::Session, @new_session.model 
     77    assert_equal @new_session.model.data, @new_session.data 
     78  end 
     79 
    7680  def teardown 
    7781    session_class.drop_table! 
     
    8084 
    8185class ColumnLimitTest < Test::Unit::TestCase 
    82  
    8386  def setup 
    8487    @session_class = CGI::Session::ActiveRecordStore::Session 
     
    98101    assert_raises(ActionController::SessionOverflowError) { s.save } 
    99102  end 
    100  
    101103end 
    102  
    103104 
    104105class DeprecatedActiveRecordStoreTest < ActiveRecordStoreTest 
     
    129130    @session_class 
    130131  end 
     132 
     133  def test_model_attribute 
     134    assert_kind_of CGI::Session::ActiveRecordStore::SqlBypass, @new_session.model 
     135    assert_equal @new_session.model.data, @new_session.data 
     136  end 
    131137end 
    132138 
     
    134140# End of safety net. 
    135141  rescue Object => e 
    136     $stderr.puts "Skipping CGI::Session::ActiveRecordStore tests: #{e}"     
     142    $stderr.puts "Skipping CGI::Session::ActiveRecordStore tests: #{e}" 
    137143    #$stderr.puts "  #{e.backtrace.join("\n  ")}" 
    138144  end 
  • trunk/actionpack/test/controller/base_test.rb

    r2277 r2696  
    6868 
    6969  def test_action_methods 
    70     @empty_controllers.each {|c| assert_equal({}, c.send(:action_methods), "#{c.class.controller_path} should be empty!")} 
    71     @non_empty_controllers.each {|c| assert_equal({"public_action"=>true}, c.send(:action_methods), "#{c.class.controller_path} should not be empty!")} 
     70    @empty_controllers.each do |c| 
     71      assert_equal Set.new, c.send(:action_methods), "#{c.class.controller_path} should be empty!" 
     72    end 
     73    @non_empty_controllers.each do |c| 
     74      assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.class.controller_path} should not be empty!" 
     75    end 
    7276  end 
    7377end