weird build behavior

27 views
Skip to first unread message

apneadiving

unread,
Jan 27, 2012, 12:01:21 PM1/27/12
to factory_girl
Hi,

I love your gem and use it daily. Today I aced a weird problem, the
following tests both pass:

it "test5bis", :focus do
user = Factory :author
doc = Factory.build(:document, :project =>
project, :original_content => "Lorem Ipsum", :status => "incomplete")
doc.persisted?.should be false
end

it "test5bisCrazy", :focus do
user = Factory :author
doc = Factory.build(:document, :original_content => "Lorem
Ipsum", :project => project, :status => "incomplete")
doc.persisted?.should be true
end

Why does the order of parameters matters?

I use FactoryGirl 2.5.0 and Mongoid.

Thanks,

Ben

Peter Vandenabeele

unread,
Feb 9, 2012, 11:57:39 AM2/9/12
to factor...@googlegroups.com


Did you override one of the setters in the document class (../app/model/document.rb) ?

Could you show the FactoryGirl.define code for the :document factories ?

Since you use "build", I should not ask for before_save, after_save (I assume).

Is "project" defined as an association ? ("build" on an association _does_ trigger
a database "create" on the associated object in some cases ...)

HTH,

Peter


*** Available for a new project ***

Peter Vandenabeele
http://twitter.com/peter_vhttp://coderwall.com/peter_v
Reply all
Reply to author
Forward
0 new messages