mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed deprecated methods on TestSession [#1801 state:resolved]
This commit is contained in:
parent
57b156b338
commit
f17c87665e
2 changed files with 21 additions and 17 deletions
|
@ -1315,10 +1315,6 @@ module ActionController #:nodoc:
|
||||||
"#{request.protocol}#{request.host}#{request.request_uri}"
|
"#{request.protocol}#{request.host}#{request.request_uri}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_session
|
|
||||||
@_session.close if @_session && @_session.respond_to?(:close)
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_template(action_name = self.action_name)
|
def default_template(action_name = self.action_name)
|
||||||
self.view_paths.find_template(default_template_name(action_name), default_template_format)
|
self.view_paths.find_template(default_template_name(action_name), default_template_format)
|
||||||
end
|
end
|
||||||
|
@ -1342,7 +1338,6 @@ module ActionController #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_cleanup
|
def process_cleanup
|
||||||
close_session
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -280,38 +280,47 @@ module ActionController #:nodoc:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestSession #:nodoc:
|
class TestSession < Hash #:nodoc:
|
||||||
attr_accessor :session_id
|
attr_accessor :session_id
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes = nil)
|
||||||
@session_id = ''
|
@session_id = ''
|
||||||
@attributes = attributes.nil? ? nil : attributes.stringify_keys
|
attributes ||= {}
|
||||||
@saved_attributes = nil
|
replace(attributes.stringify_keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
@attributes ||= @saved_attributes || {}
|
to_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
data[key.to_s]
|
super(key.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
data[key.to_s] = value
|
super(key.to_s, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update(hash = nil)
|
||||||
@saved_attributes = @attributes
|
if hash.nil?
|
||||||
|
ActiveSupport::Deprecation.warn('use replace instead', caller)
|
||||||
|
replace({})
|
||||||
|
else
|
||||||
|
super(hash)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete(key = nil)
|
||||||
@attributes = nil
|
if key.nil?
|
||||||
|
ActiveSupport::Deprecation.warn('use clear instead', caller)
|
||||||
|
clear
|
||||||
|
else
|
||||||
|
super(key.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
update
|
ActiveSupport::Deprecation.warn('sessions should no longer be closed', caller)
|
||||||
delete
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue