I have a factory for an ActiveRecord model that has an associated (uploaded) file. The file should be added to the filesystem when the factory object is "create"d but not for "build".
I can use the before(:create) callback to create the file in the filesystem. Works great. FactoryGirl.create(:qualdoc) creates the associated file.
But
The model (Qualdoc) "belongs_to" another model (Household). So the factory for Household has association :qualdoc, :strategy => :build. And the before(:create) callback for the Qualdoc factory is not called when the Household model is saved.
I need a before(:save) callback. Is it possible to do that somehow?
thanks in advance for any pointers you can offer
Les