Skip to content

Commit

Permalink
Send cookies with request
Browse files Browse the repository at this point in the history
  • Loading branch information
eileencodes authored and tenderlove committed Jul 7, 2015
1 parent 062cbd1 commit ae29142
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion actionpack/lib/action_controller/test_case.rb
Expand Up @@ -317,7 +317,9 @@ def determine_default_controller_class(name)
# 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.
Expand Down Expand Up @@ -482,6 +484,7 @@ def process(action, *args)
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!
Expand Down
4 changes: 4 additions & 0 deletions actionpack/lib/action_dispatch/middleware/cookies.rb
Expand Up @@ -279,6 +279,10 @@ def update(other_hash)
self
end

def to_header
@cookies.map { |k,v| "#{k}=#{v}" }.join ';'
end

def handle_options(options) #:nodoc:
options[:path] ||= "/"

Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/testing/test_process.rb
Expand Up @@ -19,7 +19,7 @@ def flash
end

def cookies
@request.cookie_jar
@cookie_jar ||= Cookies::CookieJar.build(@request.env, @request.host, @request.ssl?, @request.cookies)
end

def redirect_to_url
Expand Down

0 comments on commit ae29142

Please sign in to comment.