Hey I have a test that looks like this
test 'create account' do
if User.create(email: '[email protected]', password: 'blahblah')
assert true
else
assert User.msg
end
end
But when I try to run it I'm getting an error message like this:
1) Error:
UserTest#test_create_account:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_email"
DETAIL: Key (email)=() already exists.
: INSERT INTO "users" ("created_at", "updated_at", "id") VALUES ('2013-10-16 21:59:54', '2013-10-16 21:59:54', 298486374)
This looks to me as though I hadn't initialized email, but as I understand this should be initialized with my create above. I'm using strong params so I don't have any attr_accessable enabled and I can run this through. Does anyone know what could be causing this? If you want any more information let me know.
This was caused by the automatically generated fixtures from the rails scaffolding. For whatever reason this shows up inside of the tests rather than in its own section. When I fixed the fixtures this error stopped appearing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With