diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-26 11:37:11 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-26 11:37:11 -0500 |
commit | 6940c0de12eedcff6529ba0dfef533513cbcd389 (patch) | |
tree | 19391f3b35e17db87407b1eb72545df7b3f62242 /actionpack/lib/action_controller/testing | |
parent | 3cb97aeea8837b9d2b7ed3f9806f5727ceef0e3d (diff) | |
download | rails-6940c0de12eedcff6529ba0dfef533513cbcd389.tar.gz rails-6940c0de12eedcff6529ba0dfef533513cbcd389.tar.bz2 rails-6940c0de12eedcff6529ba0dfef533513cbcd389.zip |
Unify functional and integration tests cookie helpers
Diffstat (limited to 'actionpack/lib/action_controller/testing')
-rw-r--r-- | actionpack/lib/action_controller/testing/integration.rb | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb index 10260d5af2..be5f216e2b 100644 --- a/actionpack/lib/action_controller/testing/integration.rb +++ b/actionpack/lib/action_controller/testing/integration.rb @@ -285,37 +285,28 @@ module ActionController app = Rack::Lint.new(@app) status, headers, body = app.call(env) response = ::Rack::MockResponse.new(status, headers, body) + @request_count += 1 + @request = Request.new(env) - @html_document = nil + @response = Response.new + @response.status = @status = response.status + @response.headers = @headers = response.headers + @response.body = @body = response.body - @status = response.status @status_message = ActionDispatch::StatusCodes::STATUS_CODES[@status] - @headers = response.headers - @body = response.body - - (@headers['Set-Cookie'] || "").split("\n").each do |cookie| - name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2] - @cookies[name] = value - end - - if @controller = ActionController::Base.last_instantiation - @request = @controller.request - @response = @controller.response - @controller.send(:set_test_assigns) - else - @request = Request.new(env) - @response = Response.new - @response.status = @status - @response.headers = @headers - @response.body = @body - end + @cookies.merge!(@response.cookies) + @html_document = nil # Decorate the response with the standard behavior of the # TestResponse so that things like assert_response can be # used in integration tests. @response.extend(TestResponseBehavior) + if @controller = ActionController::Base.last_instantiation + @controller.send(:set_test_assigns) + end + return @status end |