lundi 7 mars 2016

Can't hit the DB, by integration testing with minitest

I keep getting test F

"User.count" didn't change by 1.

even if I should not (because SessionsController#create really works already).

Testing code is like this:

  class SessionsControllerTest < ActionDispatch::IntegrationTest

    test "should create new user" do
      # get the sigup page
      get "/sigup"
      follow_redirect!

      OmniAuth.config.test_mode = false

      # post the sigup and follow through to the home page
      assert_difference('User.count') do
        post '/auth/identity/register', user: { name: "Luca", 
                                email: "luca@prova.it",
                                password_digest: "password",
                                identities: { user_id: 1, 
                                provider: "identity", 
                                uid: "1"}}
      end
      assert_response :success
      OmniAuth.config.test_mode = true
    end

  end

The full output:

Failure:
SessionsController#test_should_create_new_user [/home/lsoave/rails5/gitwatcher/test/controllers/sessions_controller_test.rb:15]:
"User.count" didn't change by 1.
Expected: 5
  Actual: 4

Aucun commentaire:

Enregistrer un commentaire