diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1c02f25..493a3e5 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 665f46f..199eb4f 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 f1c547a..391dbc0 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'