From 30fdabc61eef6f2ce107955eaa6c8a5b526f6404 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Fri, 19 Jan 2024 00:48:30 +0100 Subject: [PATCH] fix --- spec/spec_helper.rb | 5 ----- spec/support/schema.rb | 8 ++++++++ test/test_helper.rb | 5 +---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1c02f255..493a3e56 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,11 +99,6 @@ def sqlite? # Require our gem require 'closure_tree' -ActiveRecord::Tasks::DatabaseTasks.drop_current(:primary) -ActiveRecord::Tasks::DatabaseTasks.create_current(:primary) -ActiveRecord::Tasks::DatabaseTasks.drop_current(:secondary) -ActiveRecord::Tasks::DatabaseTasks.create_current(:secondary) - # Load test helpers require_relative 'support/schema' require_relative 'support/models' diff --git a/spec/support/schema.rb b/spec/support/schema.rb index 665f46fb..199eb4f6 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true + + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true @@ -12,6 +14,12 @@ class SecondDatabaseRecord < ActiveRecord::Base connects_to database: { writing: :secondary, reading: :secondary } end +ActiveRecord::Tasks::DatabaseTasks.drop(:primary) +ActiveRecord::Tasks::DatabaseTasks.create(:primary) +ActiveRecord::Tasks::DatabaseTasks.drop(:secondary) +ActiveRecord::Tasks::DatabaseTasks.create(:secondary) + +ApplicationRecord.establish_connection ActiveRecord::Schema.define(version: 0) do connection.create_table 'tags', force: :cascade do |t| t.string 'name' diff --git a/test/test_helper.rb b/test/test_helper.rb index f1c547a3..391dbc00 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -67,10 +67,7 @@ class Spec Thread.abort_on_exception = true require 'closure_tree' -ActiveRecord::Tasks::DatabaseTasks.drop_current(:primary) -ActiveRecord::Tasks::DatabaseTasks.create_current(:primary) -ActiveRecord::Tasks::DatabaseTasks.drop_current(:secondary) -ActiveRecord::Tasks::DatabaseTasks.create_current(:secondary) + require_relative '../spec/support/schema' require_relative '../spec/support/models'