提交 4528cd0f 编写于 作者: A Aaron Patterson

extend the controller with special logic on recycle

For some reason, this special logic is only supposed to be executed on
the second request.  For now, we'll extend on recycle, but we should
figure out why this functionality can't be run on every request
上级 9eef9333
......@@ -4,18 +4,33 @@ module Testing
include RackDelegation
def recycle!
@_url_options = nil
end
# 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
# TODO: Clean this up
def process_with_new_base_test(request, response)
ret = process(request.parameters[:action])
if cookies = @_request.env['action_dispatch.cookies']
cookies.write(@_response)
def recycled?
true
end
@_response.prepare!
ret
end
def recycled? # :nodoc:
false
end
def recycle!
@_url_options = nil
extend Recycled unless recycled?
end
# TODO : Rewrite tests using controller.headers= to use Rack env
......
......@@ -497,13 +497,10 @@ def process(action, http_method = 'GET', *args)
build_request_uri(action, parameters)
@controller.class.class_eval { include Testing }
@controller.extend(Module.new {
def set_response!(request)
end
})
@controller.recycle!
@controller.process_with_new_base_test(@request, @response)
name = @request.parameters[:action]
@controller.process(name)
@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
@request.session.delete('flash') if @request.session['flash'].blank?
@response
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册