From edf9faeb28db6165f6e86df78493aacfc745f08a Mon Sep 17 00:00:00 2001 From: Mohammed Nasser <135416851+mohammednasser-32@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:44:04 +0300 Subject: [PATCH] add_before_build_callbcak --- lib/factory_bot/strategy/build.rb | 1 + lib/factory_bot/strategy/create.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/factory_bot/strategy/build.rb b/lib/factory_bot/strategy/build.rb index d18bb8ff..45720acb 100644 --- a/lib/factory_bot/strategy/build.rb +++ b/lib/factory_bot/strategy/build.rb @@ -7,6 +7,7 @@ def association(runner) def result(evaluation) evaluation.object.tap do |instance| + evaluation.notify(:before_build, instance) evaluation.notify(:after_build, instance) end end diff --git a/lib/factory_bot/strategy/create.rb b/lib/factory_bot/strategy/create.rb index c9371f42..a0ea8586 100644 --- a/lib/factory_bot/strategy/create.rb +++ b/lib/factory_bot/strategy/create.rb @@ -7,6 +7,7 @@ def association(runner) def result(evaluation) evaluation.object.tap do |instance| + evaluation.notify(:before_build, instance) evaluation.notify(:after_build, instance) evaluation.notify(:before_create, instance) evaluation.create(instance)