Devise::TestCase should complain when included after ActionController::TestCase #2073

Closed
drbrain opened this Issue Sep 27, 2012 · 3 comments

Comments

Projects
None yet
4 participants

drbrain commented Sep 27, 2012

In my app I included Devise::TestCase in MiniTest::Rails::ActiveSupport::TestCase. In this configuration it would cause the following exception:

  3) Error:
test_...(MainControllerTest):
ArgumentError: uncaught throw :warden
    /usr/local/lib/ruby/gems/1.9.1/gems/warden-1.2.1/lib/warden/proxy.rb:128:in `throw'
    /usr/local/lib/ruby/gems/1.9.1/gems/warden-1.2.1/lib/warden/proxy.rb:128:in `authenticate!'
    /usr/local/lib/ruby/gems/1.9.1/gems/devise-2.1.2/lib/devise/controllers/helpers.rb:48:in `authenticate_user!'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:418:in `_run__3989394724688411591__process_action__279290032747264474__callbacks'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/callbacks.rb:17:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/rescue.rb:29:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `block in instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/params_wrapper.rb:206:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.6/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/base.rb:121:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/rendering.rb:45:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/testing.rb:17:in `process_with_new_base_test'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/test_case.rb:469:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/test_case.rb:49:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_controller/test_case.rb:386:in `get'
    [my test]

This is because the ancestors list looks like this:

[MainControllerTest, MiniTest::Rails::ActionController::TestCase, ..., MiniTest::Rails::ActiveSupport::TestCase, #<Module:0x007feefe9d7278>, Devise::TestHelpers, ..., Kernel, BasicObject]

By moving the include to MainControllerTest the test will work, which gives the following ancestors list:

[MainControllerTest, Devise::TestHelpers, MiniTest::Rails::ActionController::TestCase, ..., MiniTest::Rails::ActiveSupport::TestCase, #<Module:0x007f91212fe888>, ..., Kernel, BasicObject]

If Devise::TestHelpers checked where it lived in the ancestors list this problem could be avoided.

Collaborator

nashby commented Nov 5, 2012

@drbrain a simple application that reproduces this issue would be super useful for me to fix it. Thank you!

fuelxc commented Jan 24, 2013

I had this same issue in an app. It turned out removal of the rack middleware Rack::FiberPool fixed whatever the issue was.

Owner

josevalim commented Apr 14, 2013

I couldn't figure out a solution that makes it work with MiniTest and RSpec. Also, I was told the Rails minitest hooks class names are private and I should not expect them to be always the same. So I am closing this unless someone has a patch in mind. :) Thanks everyone!

@josevalim josevalim closed this Apr 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment