Re: [Rails] rake test:units error because not null constraint.
On 18 November 2012 19:42, Mauro <mrsanna1@gmail.com> wrote:
> Hello.
> I have this unit test:
>
> test "User validations" do
> user = User.new
> assert user.invalid?
> assert user.errors[:uid].any?
> assert user.errors[:name].any?
> assert user.errors[:role].any?
> end
>
> When I run it I have this error:
>
> null value in column "uid" violates not-null constraint: INSERT INTO
> "users" ("created_at", "updated_at", "id") VALUES ('2012-11-18
> 19:37:39', '2012-11-18 19:37:39', 298486374).
> In the fixture user I've put:
>
> one:
> uid: "xxx.xxx"
>
> Why the unit test got the error?
Is it only that test that gives the problem or does it happen when you
run any test? If it was a problem with the fixture then it will
happen whatever test you run, I think.
I don't think that it is necessary to include quotes in the fixture
file but I would not expect that to cause the problem.
What happens if you empty the users fixtures file?
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home