diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-30 19:23:50 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-30 19:23:50 -0500 |
commit | a6fff94baf0ca5d436cbc5c0fa81f690c8024ff5 (patch) | |
tree | 56dfb7ba1bed8c06fcc1a6237cd80ac72a27877f /actionpack/lib/action_dispatch/testing | |
parent | d54604c352ca444c49e54f4dbbfcaff58f8c7d06 (diff) | |
download | rails-a6fff94baf0ca5d436cbc5c0fa81f690c8024ff5.tar.gz rails-a6fff94baf0ca5d436cbc5c0fa81f690c8024ff5.tar.bz2 rails-a6fff94baf0ca5d436cbc5c0fa81f690c8024ff5.zip |
Move TestRequest cookies accessor into AD TestRequest
Diffstat (limited to 'actionpack/lib/action_dispatch/testing')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_request.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index 3d20b466d3..bd6c26b69b 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -1,17 +1,24 @@ module ActionDispatch class TestRequest < Request + DEFAULT_ENV = Rack::MockRequest.env_for('/') + def self.new(env = {}) super end def initialize(env = {}) - super(Rack::MockRequest.env_for('/').merge(env)) + super(DEFAULT_ENV.merge(env)) self.host = 'test.host' self.remote_addr = '0.0.0.0' self.user_agent = 'Rails Testing' end + def env + write_cookies! + super + end + def request_method=(method) @env['REQUEST_METHOD'] = method.to_s.upcase end @@ -49,8 +56,19 @@ module ActionDispatch end def accept=(mime_types) - @env.delete("action_dispatch.request.accepts") - @env["HTTP_ACCEPT"] = Array(mime_types).collect { |mime_types| mime_types.to_s }.join(",") + @env.delete('action_dispatch.request.accepts') + @env['HTTP_ACCEPT'] = Array(mime_types).collect { |mime_types| mime_types.to_s }.join(",") end + + def cookies + @cookies ||= super + end + + private + def write_cookies! + unless @cookies.blank? + @env['HTTP_COOKIE'] = @cookies.map { |name, value| "#{name}=#{value};" }.join(' ') + end + end end end |