diff options
author | eileencodes <eileencodes@gmail.com> | 2015-07-07 14:36:50 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-07 14:31:34 -0700 |
commit | 8363b879fe759f0645179f4521cc64795efbee6e (patch) | |
tree | 6450bbea30d76265236a1befdce5ca2b5372289e /actionpack | |
parent | ae29142142324545a328948e059e8b8118fd7a33 (diff) | |
download | rails-8363b879fe759f0645179f4521cc64795efbee6e.tar.gz rails-8363b879fe759f0645179f4521cc64795efbee6e.tar.bz2 rails-8363b879fe759f0645179f4521cc64795efbee6e.zip |
pass cookies from the jar in the HTTP_COOKIE header
we should be pushing the cookies in via headers rather than maintaining
some object and "recycling" it.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 15 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_request.rb | 13 | ||||
-rw-r--r-- | actionpack/test/dispatch/test_request_test.rb | 2 |
3 files changed, 11 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 528c5ee1d1..9a7da54c95 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -65,14 +65,6 @@ module ActionController @method = @request_method = nil @fullpath = @ip = @remote_ip = @protocol = nil @env['action_dispatch.request.query_parameters'] = {} - @set_cookies ||= {} - @set_cookies.update(Hash[cookie_jar.instance_variable_get("@set_cookies").map{ |k,o| [k,o[:value]] }]) - deleted_cookies = cookie_jar.instance_variable_get("@delete_cookies") - @set_cookies.reject!{ |k,v| deleted_cookies.include?(k) } - cookie_jar.update(rack_cookies) - cookie_jar.update(cookies) - cookie_jar.update(@set_cookies) - cookie_jar.recycle! end private @@ -453,6 +445,10 @@ module ActionController @controller.extend(Testing::Functional) end + self.cookies.update @request.cookies + @request.env['HTTP_COOKIE'] = cookies.to_header + @request.env['action_dispatch.cookies'] = nil + @request.recycle! @response.recycle! @controller.recycle! @@ -481,6 +477,8 @@ module ActionController @controller.recycle! @controller.process(action) + @request.env.delete 'HTTP_COOKIE' + if cookies = @request.env['action_dispatch.cookies'] unless @response.committed? cookies.write(@response) @@ -522,6 +520,7 @@ module ActionController end @request = build_request + @request.env["rack.request.cookie_hash"] = {}.with_indifferent_access @response = build_response response_klass @response.request = @request diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index 4b9a088265..06e9abdd62 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -4,9 +4,10 @@ require 'rack/utils' module ActionDispatch class TestRequest < Request DEFAULT_ENV = Rack::MockRequest.env_for('/', - 'HTTP_HOST' => 'test.host', - 'REMOTE_ADDR' => '0.0.0.0', - 'HTTP_USER_AGENT' => 'Rails Testing' + 'HTTP_HOST' => 'test.host', + 'REMOTE_ADDR' => '0.0.0.0', + 'HTTP_USER_AGENT' => 'Rails Testing', + "rack.request.cookie_hash" => {}.with_indifferent_access ) def self.new(env = {}) @@ -63,12 +64,6 @@ module ActionDispatch @env['HTTP_ACCEPT'] = Array(mime_types).collect(&:to_s).join(",") end - alias :rack_cookies :cookies - - def cookies - @cookies ||= {}.with_indifferent_access - end - private def default_env diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb index cc35d4594e..a4c124070a 100644 --- a/actionpack/test/dispatch/test_request_test.rb +++ b/actionpack/test/dispatch/test_request_test.rb @@ -24,8 +24,6 @@ class TestRequestTest < ActiveSupport::TestCase assert_equal true, env.delete("rack.multithread") assert_equal true, env.delete("rack.multiprocess") assert_equal false, env.delete("rack.run_once") - - assert env.empty?, env.inspect end test "cookie jar" do |