Simplify strategy to insert records in tests
Since Rails 7.0, the `insert` method automatically generates timestamps.
This commit is contained in:
@@ -11,11 +11,7 @@ module FactoryBot
|
||||
build_class = evaluation.instance_variable_get(:@attribute_assigner)
|
||||
.instance_variable_get(:@build_class)
|
||||
|
||||
timestamps = { created_at: Time.current, updated_at: Time.current }.select do |attribute, _|
|
||||
build_class.has_attribute?(attribute)
|
||||
end
|
||||
|
||||
build_class.insert!(timestamps.merge(@strategy.result(evaluation)))
|
||||
build_class.insert!(@strategy.result(evaluation))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user