mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
1b81d5dc25
What? ===== Within FactoryBot::Evaluator, the build strategy was reported either as a class OR symbol. A side-effect of this is misreporting within ActiveSupport::Notifications hooks, since the instrumentation payload may have strategies listed as e.g. `:create` or `FactoryBot::Strategy::Create`, even though they semantically represent the same information. This introduces a new instance method for all strategies, `to_sym`, to be called rather than `class`.
22 lines
467 B
Ruby
22 lines
467 B
Ruby
module FactoryBot
|
|
module Strategy
|
|
class Create
|
|
def association(runner)
|
|
runner.run
|
|
end
|
|
|
|
def result(evaluation)
|
|
evaluation.object.tap do |instance|
|
|
evaluation.notify(:after_build, instance)
|
|
evaluation.notify(:before_create, instance)
|
|
evaluation.create(instance)
|
|
evaluation.notify(:after_create, instance)
|
|
end
|
|
end
|
|
|
|
def to_sym
|
|
:create
|
|
end
|
|
end
|
|
end
|
|
end
|