File tree Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 27
27
ActiveRecord . raise_on_assign_to_attr_readonly = true
28
28
ActiveRecord . belongs_to_required_validates_foreign_key = false
29
29
30
- def load_schema
31
- # silence verbose schema loading
32
- original_stdout = $stdout
33
- $stdout = StringIO . new
34
-
35
- adapter_name = ActiveRecord ::Base . connection . adapter_name . downcase
36
- adapter_specific_schema_file = SCHEMA_ROOT + "/#{ adapter_name } _specific_schema.rb"
37
-
38
- load SCHEMA_ROOT + "/schema.rb"
39
-
40
- if File . exist? ( adapter_specific_schema_file )
41
- load adapter_specific_schema_file
42
- end
43
-
44
- ActiveRecord ::FixtureSet . reset_cache
45
- ensure
46
- $stdout = original_stdout
47
- end
48
-
49
- load_schema
50
-
51
30
class SQLSubscriber
52
31
attr_reader :logged
53
32
attr_reader :payloads
Original file line number Diff line number Diff line change 11
11
require_relative "../support/config"
12
12
require_relative "../support/connection"
13
13
require_relative "../support/adapter_helper"
14
+ require_relative "../support/load_schema_helper"
14
15
15
16
module ActiveRecord
16
17
# = Active Record Test Case
@@ -23,6 +24,8 @@ class TestCase < ActiveSupport::TestCase # :nodoc:
23
24
include ActiveRecord ::ValidationsRepairHelper
24
25
include AdapterHelper
25
26
extend AdapterHelper
27
+ include LoadSchemaHelper
28
+ extend LoadSchemaHelper
26
29
27
30
self . fixture_path = FIXTURES_ROOT
28
31
self . use_instantiated_fixtures = false
@@ -225,6 +228,8 @@ def clean_up_connection_handler
225
228
226
229
# Connect to the database
227
230
ARTest . connect
231
+ # Load database schema
232
+ load_schema
228
233
end
229
234
230
235
class PostgreSQLTestCase < TestCase
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module LoadSchemaHelper
4
+ def load_schema
5
+ # silence verbose schema loading
6
+ original_stdout = $stdout
7
+ $stdout = StringIO . new
8
+
9
+ adapter_name = ActiveRecord ::Base . connection . adapter_name . downcase
10
+ adapter_specific_schema_file = SCHEMA_ROOT + "/#{ adapter_name } _specific_schema.rb"
11
+
12
+ load SCHEMA_ROOT + "/schema.rb"
13
+
14
+ if File . exist? ( adapter_specific_schema_file )
15
+ load adapter_specific_schema_file
16
+ end
17
+
18
+ ActiveRecord ::FixtureSet . reset_cache
19
+ ensure
20
+ $stdout = original_stdout
21
+ end
22
+ end
You can’t perform that action at this time.
0 commit comments