Skip to content

Commit

Permalink
push the cookie writing stuff out of the controller
Browse files Browse the repository at this point in the history
merging cookies is responsibility of the test runner
  • Loading branch information
tenderlove committed Jul 3, 2012
1 parent 4528cd0 commit e136fbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
25 changes: 2 additions & 23 deletions actionpack/lib/action_controller/metal/testing.rb
Expand Up @@ -4,33 +4,12 @@ module Testing

include RackDelegation

# This gets included on the second request. We only want to modify this
# behavior on the second request. Ugh.
module Recycled # :nodoc:
def set_response!(request)
end

def process(name)
ret = super
if cookies = @_request.env['action_dispatch.cookies']
cookies.write(@_response)
end
@_response.prepare!
ret
end

def recycled?
true
end
end

def recycled? # :nodoc:
false
def set_response!(request)
super unless @_response
end

def recycle!
@_url_options = nil
extend Recycled unless recycled?
end

# TODO : Rewrite tests using controller.headers= to use Rack env
Expand Down
6 changes: 6 additions & 0 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -499,8 +499,14 @@ def process(action, http_method = 'GET', *args)

@controller.recycle!
name = @request.parameters[:action]

@controller.process(name)

if cookies = @request.env['action_dispatch.cookies']
cookies.write(@response)
end
@response.prepare!

@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
@request.session.delete('flash') if @request.session['flash'].blank?
@response
Expand Down

0 comments on commit e136fbd

Please sign in to comment.