diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-27 13:11:17 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-27 13:11:17 -0500 |
commit | 21aa32692caf91f56d1c5c411baae635fa398344 (patch) | |
tree | 1b9c59452e40f6908599196598b7c07a6d07dee0 /actionpack | |
parent | dde063507ac40fda1a67f06a54c1a57d237f57b2 (diff) | |
download | rails-21aa32692caf91f56d1c5c411baae635fa398344.tar.gz rails-21aa32692caf91f56d1c5c411baae635fa398344.tar.bz2 rails-21aa32692caf91f56d1c5c411baae635fa398344.zip |
Delegate controller.session to request.session and deprecate response session
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/base/base.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_controller/testing/process.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_dispatch/http/request.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 6 |
5 files changed, 11 insertions, 25 deletions
diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index afb9fb71cb..1d0738588d 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -238,7 +238,7 @@ module ActionController #:nodoc: cattr_reader :protected_instance_variables # Controller specific instance variables which will not be accessible inside views. @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller - @action_name @before_filter_chain_aborted @action_cache_path @_session @_headers @_params + @action_name @before_filter_chain_aborted @action_cache_path @_headers @_params @_flash @_response) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, @@ -356,7 +356,9 @@ module ActionController #:nodoc: # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string or symbol. - attr_internal :session + def session + request.session + end # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control # directive. Values should always be specified as strings. @@ -787,7 +789,6 @@ module ActionController #:nodoc: # Resets the session by clearing out all the objects stored within and initializing a new session object. def reset_session #:doc: request.reset_session - @_session = request.session end private @@ -812,7 +813,7 @@ module ActionController #:nodoc: def assign_shortcuts(request, response) @_request, @_response, @_params = request, response, request.parameters - @_session, @_headers = @_request.session, @_response.headers + @_headers = @_response.headers end def initialize_current_url @@ -888,10 +889,6 @@ module ActionController #:nodoc: "#{request.protocol}#{request.host}#{request.request_uri}" end - def close_session - # @_session.close if @_session && @_session.respond_to?(:close) - end - def default_template(action_name = self.action_name) self.view_paths.find_template(default_template_name(action_name), default_template_format) end @@ -915,7 +912,6 @@ module ActionController #:nodoc: end def process_cleanup - close_session end end diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index c532a67e78..d073d06b19 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -165,7 +165,7 @@ module ActionController #:nodoc: # A shortcut to the flash. Returns an empty hash if no session flash exists. def flash - session['flash'] || {} + request.session['flash'] || {} end # Do we have a flash? diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 0b8909ced7..2602b344ca 100755 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -451,14 +451,6 @@ EOM @env['rack.input'] end - def session - @env['rack.session'] - end - - def session_options - @env['rack.session.options'] - end - def reset_session self.session_options.delete(:id) self.session = {} diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 6c92fb9713..ebba4eefa0 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -40,7 +40,11 @@ module ActionDispatch # :nodoc: attr_writer :header alias_method :headers=, :header= - delegate :session, :to => :request + def session + ActiveSupport::Deprecation.warn("response.session has been deprecated. Use request.session instead", caller) + request.session + end + delegate :default_charset, :to => 'ActionController::Base' def initialize diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 124e259ef6..f68ffc7a2a 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -184,12 +184,6 @@ XML assert_equal Hash.new, @controller.session.to_hash end - def test_session_is_cleared_from_response_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @response.session.to_hash - end - def test_session_is_cleared_from_request_after_reset_session process :set_session process :reset_the_session |