diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2011-03-30 00:46:27 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2011-06-04 07:09:11 +0100 |
commit | d4658d86fe7b037f2105e798a5717e22ca55d61d (patch) | |
tree | 51902717a0b8881534a9e978db7502eff9a1e26c /actionpack/lib/action_dispatch/testing/test_request.rb | |
parent | 64325a82427120cf7659c80e1b67ca1ffb01ebc4 (diff) | |
download | rails-d4658d86fe7b037f2105e798a5717e22ca55d61d.tar.gz rails-d4658d86fe7b037f2105e798a5717e22ca55d61d.tar.bz2 rails-d4658d86fe7b037f2105e798a5717e22ca55d61d.zip |
Refactor ActionController::TestCase cookies
Assigning cookies for test cases should now use cookies[], e.g:
cookies[:email] = 'user@example.com'
get :index
assert_equal 'user@example.com', cookies[:email]
To clear the cookies, use clear, e.g:
cookies.clear
get :index
assert_nil cookies[:email]
We now no longer write out HTTP_COOKIE and the cookie jar is
persistent between requests so if you need to manipulate the environment
for your test you need to do it before the cookie jar is created.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/test_request.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_request.rb | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index 822adb6a47..5c16023137 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -20,12 +20,6 @@ module ActionDispatch self.user_agent = 'Rails Testing' end - def env - write_cookies! - delete_nil_values! - super - end - def request_method=(method) @env['REQUEST_METHOD'] = method.to_s.upcase end @@ -70,24 +64,5 @@ module ActionDispatch @env.delete('action_dispatch.request.accepts') @env['HTTP_ACCEPT'] = Array(mime_types).collect { |mime_type| mime_type.to_s }.join(",") end - - def cookies - @cookies ||= super - end - - private - def write_cookies! - unless @cookies.blank? - @env['HTTP_COOKIE'] = @cookies.map { |name, value| escape_cookie(name, value) }.join('; ') - end - end - - def escape_cookie(name, value) - "#{Rack::Utils.escape(name)}=#{Rack::Utils.escape(value)}" - end - - def delete_nil_values! - @env.delete_if { |k, v| v.nil? } - end end end |