diff options
author | eileencodes <eileencodes@gmail.com> | 2015-07-07 14:36:18 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-07 14:31:34 -0700 |
commit | ae29142142324545a328948e059e8b8118fd7a33 (patch) | |
tree | 280e5683ca97750f81b2dc6d74997eafcb05705f | |
parent | 062cbd18ddbf6ef48c9a9a2a69081737aebbee89 (diff) | |
download | rails-ae29142142324545a328948e059e8b8118fd7a33.tar.gz rails-ae29142142324545a328948e059e8b8118fd7a33.tar.bz2 rails-ae29142142324545a328948e059e8b8118fd7a33.zip |
Send cookies with request
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_process.rb | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 96f161fb09..528c5ee1d1 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -317,7 +317,9 @@ module ActionController # Note that the request method is not verified. The different methods are # available to make the tests more expressive. def get(action, *args) - process_with_kwargs("GET", action, *args) + res = process_with_kwargs("GET", action, *args) + cookies.update res.cookies + res end # Simulate a POST request with the given parameters and set/volley the response. @@ -482,6 +484,7 @@ module ActionController if cookies = @request.env['action_dispatch.cookies'] unless @response.committed? cookies.write(@response) + self.cookies.update(cookies.instance_variable_get(:@cookies)) end end @response.prepare! diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 9a1e2bd45c..07d97bd6bd 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -279,6 +279,10 @@ module ActionDispatch self end + def to_header + @cookies.map { |k,v| "#{k}=#{v}" }.join ';' + end + def handle_options(options) #:nodoc: options[:path] ||= "/" diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 415ef80cd2..494644cd46 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -19,7 +19,7 @@ module ActionDispatch end def cookies - @request.cookie_jar + @cookie_jar ||= Cookies::CookieJar.build(@request.env, @request.host, @request.ssl?, @request.cookies) end def redirect_to_url |