Changeset 2031
- Timestamp:
- 08/17/05 21:05:31 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/session_management.rb
r1886 r2031 33 33 # session :only => :foo, :session_secure => true 34 34 # 35 # # the session will only be disabled for 'foo', and only if it is 36 # # requested as a web service 37 # session :off, :only => :foo, 38 # :if => Proc.new { |req| req.parameters[:ws] } 39 # 35 40 # All session options described for ActionController::Base.process_cgi 36 41 # are valid arguments. … … 48 53 end 49 54 50 def session_options_for( action) #:nodoc:55 def session_options_for(request, action) #:nodoc: 51 56 options = {} 52 57 53 58 action = action.to_s 54 59 (read_inheritable_attribute("session_options") || []).each do |opts| 60 next if opts[:if] && !opts[:if].call(request) 55 61 if opts[:only] && opts[:only].include?(action) 56 62 options.merge!(opts) … … 64 70 options.delete :only 65 71 options.delete :except 72 options.delete :if 66 73 67 74 options[:disabled] ? false : options … … 71 78 def process_with_session_management_support(request, response, method = :perform_action, *arguments) #:nodoc: 72 79 action = request.parameters["action"] || "index" 73 request.session_options = self.class.session_options_for( action)80 request.session_options = self.class.session_options_for(request, action) 74 81 process_without_session_management_support(request, response, method, *arguments) 75 82 end trunk/actionpack/test/controller/session_management_test.rb
r1888 r2031 17 17 session :off, :only => :show 18 18 session :session_secure => true, :except => :show 19 session :off, :only => :conditional, 20 :if => Proc.new { |r| r.parameters[:ws] } 19 21 20 22 def show … … 24 26 def tell 25 27 render_text "done" 28 end 29 30 def conditional 31 render_text ">>>#{params[:ws]}<<<" 26 32 end 27 33 end … … 68 74 assert_equal false, @request.session_options 69 75 end 76 77 def test_session_off_with_if 78 @controller = TestController.new 79 get :conditional 80 assert_instance_of Hash, @request.session_options 81 get :conditional, :ws => "ws" 82 assert_equal false, @request.session_options 83 end 70 84 end