Devise: Devise::Test::IntegrationHelpers still throws warden exception

Created on 19 Aug 2016  路  4Comments  路  Source: heartcombo/devise

Hi,

I'm using 4.2.0 of devise and running ActionDispatch::Integration tests, but for two methods that I force a user to login, i'm getting strange warden through errors. Here's a snippet:

class FlatsControllerTest < ActionDispatch::IntegrationTest
  include Devise::Test::IntegrationHelpers
  setup do
    @flat = flats(:one)
  end

  test "should get index" do
    get flats_url
    assert_response :success
  end

  test "should get new" do
    get new_flat_url
    assert_response :success
  end

  test "should create flat" do
    sign_in users(:user_one), scope: :user
    assert_difference('Flat.count') do
      post flats_url, params: { flat: {building_name: @flat.building_name } }
    end

    assert_redirected_to flat_url(Flat.last)
  end

  test "should get edit" do
    sign_in users(:user_one)
    get edit_flat_url(@flat)
    assert_response :success
  end

end

For the two methods of edit and create, I get:

Error:
FlatsControllerTest#test_should_create_flat:
UncaughtThrowError: uncaught throw :warden
    test/controllers/flats_controller_test.rb:22:in `block (2 levels) in <class:FlatsControllerTest>'
    test/controllers/flats_controller_test.rb:21:in `block in <class:FlatsControllerTest>'

Error:
FlatsControllerTest#test_should_get_edit:
UncaughtThrowError: uncaught throw :warden
    test/controllers/flats_controller_test.rb:35:in `block in <class:FlatsControllerTest>'

Both of those lines are for the get or post methods that are being called. It looks like the sign_in method is not actually signing in my user from my fixtures. Here's my fixture:

user_one:
  first_name: Joe
  last_name: Schmoe
  email: [email protected]

I've tried using both with and without the scope. What am I missing?

Most helpful comment

@lucasmazza got it! seems to be from confirmable module. I set my users to have to be confirmed. So I guess I need to manually confirm them before they can sign in?

All 4 comments

Can you please provide a sample application that reproduces the error?

fun! :) I'll give it a go. Should be fairly simple to reproduce, since I haven't done much outside of what you can see.

@lucasmazza i think i have an idea of what it is. looks like maybe it's when you have a large model, which I happen to have. let me see if I can really reproduce. I noticed taht it only happens when i pass in my model to the url params.

@lucasmazza got it! seems to be from confirmable module. I set my users to have to be confirmed. So I guess I need to manually confirm them before they can sign in?

Was this page helpful?
0 / 5 - 0 ratings