factory-girl icon indicating copy to clipboard operation
factory-girl copied to clipboard

inherit buildOptions in extended factories

Open sienic opened this issue 3 years ago • 0 comments

Probably the solution to: https://github.com/simonexmachina/factory-girl/issues/134

  • Given a parentFactory defined with buildOptions with its respective callbacks.
  • Given a childFactory that extends that parentFactory.
  • Whenever a models is built out of the aforementioned childFactory,
  • the callbacks defined in the parentFactory are not being called.
const parentFactory = FactoryGirl.define('parent', Model, initializer, buildOptions);
const childFactory = FactoryGirl.extend('parent', 'child');

// whenever we build a childFactory, i.e.
await FactoryGirl.build('child');
// the `afterBuild`, and `afterCreate` callbacks set in parentFactory are not being called

This PR tries to solve this.

sienic avatar Sep 19 '20 19:09 sienic