diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-02 14:43:56 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-03 14:59:31 -0700 |
commit | 4528cd0f4372a74417ecbecf82e02bc6a3550825 (patch) | |
tree | 4491b77ac08da1c6ef70b2cc80e6a6e53c75818e /actionpack/lib | |
parent | 9eef9333bdc9631e1b0149fee86a491b603858b3 (diff) | |
download | rails-4528cd0f4372a74417ecbecf82e02bc6a3550825.tar.gz rails-4528cd0f4372a74417ecbecf82e02bc6a3550825.tar.bz2 rails-4528cd0f4372a74417ecbecf82e02bc6a3550825.zip |
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
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/testing.rb | 35 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 9 |
2 files changed, 28 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/metal/testing.rb b/actionpack/lib/action_controller/metal/testing.rb index a4718376aa..838da3322d 100644 --- a/actionpack/lib/action_controller/metal/testing.rb +++ b/actionpack/lib/action_controller/metal/testing.rb @@ -4,18 +4,33 @@ module ActionController 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 diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 9c73aba22a..480297368f 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -497,13 +497,10 @@ module ActionController 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 |