mirror of https://github.com/rails/rails
Move load_schema from Object to AR::TestCase
as its instance and class mathod
This commit is contained in:
parent
946bc94e82
commit
b378293c0d
|
@ -27,27 +27,6 @@ QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name("type")
|
|||
ActiveRecord.raise_on_assign_to_attr_readonly = true
|
||||
ActiveRecord.belongs_to_required_validates_foreign_key = false
|
||||
|
||||
def load_schema
|
||||
# silence verbose schema loading
|
||||
original_stdout = $stdout
|
||||
$stdout = StringIO.new
|
||||
|
||||
adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
|
||||
adapter_specific_schema_file = SCHEMA_ROOT + "/#{adapter_name}_specific_schema.rb"
|
||||
|
||||
load SCHEMA_ROOT + "/schema.rb"
|
||||
|
||||
if File.exist?(adapter_specific_schema_file)
|
||||
load adapter_specific_schema_file
|
||||
end
|
||||
|
||||
ActiveRecord::FixtureSet.reset_cache
|
||||
ensure
|
||||
$stdout = original_stdout
|
||||
end
|
||||
|
||||
load_schema
|
||||
|
||||
class SQLSubscriber
|
||||
attr_reader :logged
|
||||
attr_reader :payloads
|
||||
|
|
|
@ -11,6 +11,7 @@ require "cases/validations_repair_helper"
|
|||
require_relative "../support/config"
|
||||
require_relative "../support/connection"
|
||||
require_relative "../support/adapter_helper"
|
||||
require_relative "../support/load_schema_helper"
|
||||
|
||||
module ActiveRecord
|
||||
# = Active Record Test Case
|
||||
|
@ -23,6 +24,8 @@ module ActiveRecord
|
|||
include ActiveRecord::ValidationsRepairHelper
|
||||
include AdapterHelper
|
||||
extend AdapterHelper
|
||||
include LoadSchemaHelper
|
||||
extend LoadSchemaHelper
|
||||
|
||||
self.fixture_path = FIXTURES_ROOT
|
||||
self.use_instantiated_fixtures = false
|
||||
|
@ -225,6 +228,8 @@ module ActiveRecord
|
|||
|
||||
# Connect to the database
|
||||
ARTest.connect
|
||||
# Load database schema
|
||||
load_schema
|
||||
end
|
||||
|
||||
class PostgreSQLTestCase < TestCase
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module LoadSchemaHelper
|
||||
def load_schema
|
||||
# silence verbose schema loading
|
||||
original_stdout = $stdout
|
||||
$stdout = StringIO.new
|
||||
|
||||
adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
|
||||
adapter_specific_schema_file = SCHEMA_ROOT + "/#{adapter_name}_specific_schema.rb"
|
||||
|
||||
load SCHEMA_ROOT + "/schema.rb"
|
||||
|
||||
if File.exist?(adapter_specific_schema_file)
|
||||
load adapter_specific_schema_file
|
||||
end
|
||||
|
||||
ActiveRecord::FixtureSet.reset_cache
|
||||
ensure
|
||||
$stdout = original_stdout
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue