First, we use %{user_id: user.id, product_id: pid, stars: 5}
to create a rating. But then, when we try to create another record to test the unique constraint for the same user_id
and product_id
the product_id
is hardcoded to 1
: Survey.create_rating(%{user_id: user.id, product_id: 1, stars: 1})