aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/test_process.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/test_process.rb')
-rw-r--r--actionpack/lib/action_controller/test_process.rb48
1 files changed, 29 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 22b97fc157..ea17363c47 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -35,7 +35,6 @@ module ActionController #:nodoc:
def port=(number)
@env["SERVER_PORT"] = number.to_i
- port(true)
end
def action=(action_name)
@@ -49,8 +48,6 @@ module ActionController #:nodoc:
@env["REQUEST_URI"] = value
@request_uri = nil
@path = nil
- request_uri(true)
- path(true)
end
def request_uri=(uri)
@@ -58,9 +55,13 @@ module ActionController #:nodoc:
@path = uri.split("?").first
end
+ def request_method=(method)
+ @request_method = method
+ end
+
def accept=(mime_types)
@env["HTTP_ACCEPT"] = Array(mime_types).collect { |mime_types| mime_types.to_s }.join(",")
- accepts(true)
+ @accepts = nil
end
def if_modified_since=(last_modified)
@@ -76,11 +77,11 @@ module ActionController #:nodoc:
end
def request_uri(*args)
- @request_uri || super
+ @request_uri || super()
end
def path(*args)
- @path || super
+ @path || super()
end
def assign_parameters(controller_path, action, parameters)
@@ -107,7 +108,7 @@ module ActionController #:nodoc:
def recycle!
self.query_parameters = {}
self.path_parameters = {}
- unmemoize_all
+ @headers, @request_method, @accepts, @content_type = nil, nil, nil, nil
end
def user_agent=(user_agent)
@@ -279,38 +280,47 @@ module ActionController #:nodoc:
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