0

Rails 5, ruby 2.4.0 Error: rails while running rails test

Mysql2::Error: Column 'encrypted_password' cannot be null

My test: utilities_controller_test.rb

require 'test_helper'

class UsersControllerTest < ActionDispatch::IntegrationTest
  test "Has first name vidur" do
    get users_update_address_url
    assert_equal "vidur", users(:regular).first_name
  end

end

My Fixture: users.yml

admin:
 id: 1
 first_name: admin
 last_name: tukaweb
 email: '[email protected]'
 encrypted_password: <% Devise::Encryptor.digest(User, 'password') %>

regular:
 id: 2
 first_name: vidur
 last_name: punj
 email: '[email protected]'
 encrypted_password: <% Devise::Encryptor.digest(User, 'password') %>

1 Answer 1

1

You probably want to print the output of that Ruby code instead of just evaluating it, so you'll want to change your ERB delimiters from the evaluate-only to output.

In other words, change

<% %> to <%= %>

So in your case:

encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.