From ce01032b1366814b512bdd3b770409925965529e Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Jun 2024 07:52:46 -0400 Subject: [PATCH 1/3] Update railtie to set Oaken as the fixture replacement * See: * https://github.com/search?q=repo%3Arails%2Frails%20fixture_replacement&type=code * https://github.com/search?q=repo%3Athoughtbot%2Ffactory_bot_rails%20fixture_replacement&type=code * https://github.com/thoughtbot/factory_bot_rails#generators --- lib/oaken/railtie.rb | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/oaken/railtie.rb b/lib/oaken/railtie.rb index 08c0d4e..4858e5c 100644 --- a/lib/oaken/railtie.rb +++ b/lib/oaken/railtie.rb @@ -1,5 +1,23 @@ -class Oaken::Railtie < Rails::Railtie - initializer "oaken.lookup_paths" do - Oaken.lookup_paths << "db/seeds/#{Rails.env}" +module Oaken + class Railtie < Rails::Railtie + initializer "oaken.set_fixture_replacement" do + GeneratorConfiguration.run(config) + end + + initializer "oaken.lookup_paths" do + Oaken.lookup_paths << "db/seeds/#{Rails.env}" + end end -end + + class GeneratorConfiguration + def self.run(config) + test_framework = config.app_generators.options[:rails][:test_framework] + + config.app_generators.test_framework( + test_framework, + fixture: false, + fixture_replacement: :oaken + ) + end + end +end \ No newline at end of file From 1396de7128b4f78c77ae97be387d790212757607 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 28 Jun 2024 16:53:20 +0200 Subject: [PATCH 2/3] Disable Fixtures when using Oaken. We don't have a fixture_replacement, so I don't think we should set that. I did some digging in the code and this invocation is the same as the previous commit when running with Rails' default test setup. --- lib/oaken/railtie.rb | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/oaken/railtie.rb b/lib/oaken/railtie.rb index 4858e5c..6cc7aae 100644 --- a/lib/oaken/railtie.rb +++ b/lib/oaken/railtie.rb @@ -1,23 +1,9 @@ module Oaken class Railtie < Rails::Railtie - initializer "oaken.set_fixture_replacement" do - GeneratorConfiguration.run(config) - end + config.app_generators.test_unit fixture: false initializer "oaken.lookup_paths" do Oaken.lookup_paths << "db/seeds/#{Rails.env}" end end - - class GeneratorConfiguration - def self.run(config) - test_framework = config.app_generators.options[:rails][:test_framework] - - config.app_generators.test_framework( - test_framework, - fixture: false, - fixture_replacement: :oaken - ) - end - end -end \ No newline at end of file +end From d732c585385d3588867cd3f1aa83a07a58e256dc Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 28 Jun 2024 17:10:37 +0200 Subject: [PATCH 3/3] Slight revert: hopefully handle RSpec with this version too --- lib/oaken/railtie.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/oaken/railtie.rb b/lib/oaken/railtie.rb index 6cc7aae..da0a119 100644 --- a/lib/oaken/railtie.rb +++ b/lib/oaken/railtie.rb @@ -1,6 +1,8 @@ module Oaken class Railtie < Rails::Railtie - config.app_generators.test_unit fixture: false + config.app_generators do + _1.test_framework _1.test_framework, fixture: false + end initializer "oaken.lookup_paths" do Oaken.lookup_paths << "db/seeds/#{Rails.env}"