Skip to content

Commit

Permalink
Fixed deprecated methods on TestSession [#1801 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 27, 2009
1 parent 57b156b commit f17c876
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
5 changes: 0 additions & 5 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -1315,10 +1315,6 @@ def complete_request_uri
"#{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
Expand All @@ -1342,7 +1338,6 @@ def template_path_includes_controller?(path)
end

def process_cleanup
close_session
end
end

Expand Down
33 changes: 21 additions & 12 deletions actionpack/lib/action_controller/test_process.rb
Expand Up @@ -280,38 +280,47 @@ def recycle!
end
end

class TestSession #:nodoc:
class TestSession < Hash #:nodoc:
attr_accessor :session_id

def initialize(attributes = nil)
@session_id = ''
@attributes = attributes.nil? ? nil : attributes.stringify_keys
@saved_attributes = nil
attributes ||= {}
replace(attributes.stringify_keys)
end

def data
@attributes ||= @saved_attributes || {}
to_hash
end

def [](key)
data[key.to_s]
super(key.to_s)
end

def []=(key, value)
data[key.to_s] = value
super(key.to_s, value)
end

def update
@saved_attributes = @attributes
def update(hash = nil)
if hash.nil?
ActiveSupport::Deprecation.warn('use replace instead', caller)
replace({})
else
super(hash)
end
end

def delete
@attributes = nil
def delete(key = nil)
if key.nil?
ActiveSupport::Deprecation.warn('use clear instead', caller)
clear
else
super(key.to_s)
end
end

def close
update
delete
ActiveSupport::Deprecation.warn('sessions should no longer be closed', caller)
end
end

Expand Down

1 comment on commit f17c876

@adkron
Copy link
Contributor

@adkron adkron commented on f17c876 Jan 27, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were the tests not taken form the Lighthouse ticket patch?

Please sign in to comment.