1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor cookie_jar to decouple it from request object

This change decouples `cookie_jar` allocation from the request object.
We need this for moving controller tests to integration tests so we can
access the `cookie_jar` object separately.
This commit is contained in:
eileencodes 2015-07-05 12:59:24 -04:00
parent 5294bf1ef6
commit a05e245ca5

View file

@ -8,7 +8,7 @@ require 'active_support/json'
module ActionDispatch
class Request < Rack::Request
def cookie_jar
env['action_dispatch.cookies'] ||= Cookies::CookieJar.build(self)
env['action_dispatch.cookies'] ||= Cookies::CookieJar.build(env, host, ssl?, cookies)
end
end
@ -228,16 +228,12 @@ module ActionDispatch
}
end
def self.build(request)
env = request.env
def self.build(env, host, secure, cookies)
key_generator = env[GENERATOR_KEY]
options = options_for_env env
host = request.host
secure = request.ssl?
new(key_generator, host, secure, options).tap do |hash|
hash.update(request.cookies)
hash.update(cookies)
end
end