From a56e1bf3cf1c409d0fbbcc1d5f7f05f7992007cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 6 Apr 2024 05:07:18 +0200 Subject: [PATCH] Simplify strategy to insert records in tests Since Rails 7.0, the `insert` method automatically generates timestamps. --- spec/factory_bot/strategy/insert.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/factory_bot/strategy/insert.rb b/spec/factory_bot/strategy/insert.rb index 5c7468a25..9de345d1c 100644 --- a/spec/factory_bot/strategy/insert.rb +++ b/spec/factory_bot/strategy/insert.rb @@ -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