Estoy haciendo un test de integracion que antes de instalar devise funcionaba. Ahora arroja error por una llave duplicada. Tratando de insertar un usuario. La cosa es que estoy haciendo y probando los test es para un modelo Categoria que no tiene ni siquiera asociacion. Les dejo el codigo y el error. Gracias
require 'test_helper'
class CreateCategoriesTest < ActionDispatch::IntegrationTest
test "get new category form and create category" do
get new_category_path
assert_template 'categories/new'
assert_difference 'Category.count', 1 do
post categories_path, params: { category: { name: "measure tension", description: "This is the Category for measure tension"} }
follow_redirect!
end
assert_template 'categories/index'
assert_match "measure tension", response.body
end
end
El error es el siguiente:
Running via Spring preloader in process 14544
Run options: --seed 57420
# Running:
E
Error:
CreateCategoriesTest#test_get_new_category_form_and_create_category:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: llave duplicada viola restricción de unicidad «index_users_on_email»
DETAIL: Ya existe la llave (email)=().
: DELETE FROM "categories";
DELETE FROM "users";
INSERT INTO "categories" ("id", "name", "description", "created_at", "updated_at") VALUES (980190962, 'MyString', 'MyText', '2020-03-06 20:25:00.457344', '2020-03-06 20:25:00.457344'), (298486374, 'MyString', 'MyText', '2020-03-06 20:25:00.457344', '2020-03-06 20:25:00.457344');
INSERT INTO "users" ("id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "created_at", "updated_at") VALUES (980190962, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2020-03-06 20:25:00.463209', '2020-03-06 20:25:00.463209'), (298486374, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2020-03-06 20:25:00.463209', '2020-03-06 20:25:00.463209')
Error:
CreateCategoriesTest#test_get_new_category_form_and_create_category:
NoMethodError: undefined method `each' for nil:NilClass
bin/rails test test/integration/create_categories_test.rb:5
Finished in 0.023791s, 42.0323 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
Agradezco la ayuda. Muchas gracias