Skip to content

Commit f181236

Browse files
committed
Load schema root for SQL Server using new test/support dir.
* We have a new `ARTest::Sqlserver` namespace. * Rails will be moving all their patches to `ARTest` too vs root. * Previous commit fixed loading AR schema twice.
1 parent d608594 commit f181236

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

test/cases/helper_sqlserver.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
SQLSERVER_ASSETS_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'assets'))
33
SQLSERVER_FIXTURES_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'fixtures'))
44
SQLSERVER_MIGRATIONS_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'migrations'))
5-
SQLSERVER_SCHEMA_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'schema'))
65
ACTIVERECORD_TEST_ROOT = File.expand_path(File.join(Gem.loaded_specs['activerecord'].full_gem_path,'test'))
76

87
ENV['ARCONFIG'] = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'config.yml'))
@@ -18,6 +17,7 @@
1817
require 'minitest-spec-rails/init/active_support'
1918
require 'minitest-spec-rails/init/mini_shoulda'
2019
require 'cases/helper'
20+
require 'support/load_schema_sqlserver'
2121
require 'cases/sqlserver_test_case'
2222

2323
# A module that we can include in classes where we want to override an active record test.
@@ -103,7 +103,3 @@ def with_auto_connect(boolean)
103103
end
104104

105105
require 'mocha/mini_test'
106-
107-
# SQL Server.
108-
sqlserver_specific_schema_file = "#{SQLSERVER_SCHEMA_ROOT}/sqlserver_specific_schema.rb"
109-
eval(File.read(sqlserver_specific_schema_file)) unless ENV["SKIP_SCHEMA"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module ARTest
2+
module Sqlserver
3+
4+
extend self
5+
6+
def schema_root
7+
File.join SQLSERVER_TEST_ROOT, 'schema'
8+
end
9+
10+
def schema_file
11+
File.join schema_root, 'sqlserver_specific_schema.rb'
12+
end
13+
14+
def load_schema
15+
original_stdout = $stdout
16+
$stdout = StringIO.new
17+
load schema_file
18+
ensure
19+
$stdout = original_stdout
20+
end
21+
22+
end
23+
end
24+
25+
ARTest::Sqlserver.load_schema

0 commit comments

Comments
 (0)