Skip to content

Commit 92d4b1b

Browse files
committed
Support latest 3-1-stable ActiveRecord test conventions from Jon Leighton's work.
1 parent 76973a6 commit 92d4b1b

File tree

6 files changed

+48
-71
lines changed

6 files changed

+48
-71
lines changed

Rakefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require 'rake/testtask'
77
def test_libs(mode='dblib')
88
['lib',
99
'test',
10-
"test/connections/#{mode}",
1110
"#{ENV['RAILS_SOURCE']}/activerecord/test"]
1211
end
1312

@@ -24,6 +23,7 @@ end
2423
task :test => ['test:dblib']
2524
task :default => [:test]
2625

26+
2727
namespace :test do
2828

2929
['dblib','odbc'].each do |mode|
@@ -36,8 +36,19 @@ namespace :test do
3636

3737
end
3838

39+
task 'dblib:env' do
40+
ENV['ARCONN'] = 'dblib'
41+
end
42+
43+
task 'odbc:env' do
44+
ENV['ARCONN'] = 'odbc'
45+
end
46+
3947
end
4048

49+
task 'test:dblib' => 'test:dblib:env'
50+
task 'test:odbc' => 'test:odbc:env'
51+
4152

4253
namespace :profile do
4354

test/cases/sqlserver_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
SQLSERVER_MIGRATIONS_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'migrations'))
66
SQLSERVER_SCHEMA_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'schema'))
77
ACTIVERECORD_TEST_ROOT = File.expand_path(File.join(ENV['RAILS_SOURCE'],'activerecord','test'))
8+
ENV['ARCONFIG'] = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'config.yml'))
89

910
require 'rubygems'
1011
require 'bundler'
@@ -81,8 +82,10 @@ def method_added(method)
8182

8283
module ActiveRecord
8384
class SQLCounter
84-
IGNORED_SQL << %r|SELECT SCOPE_IDENTITY| << %r{INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS)} <<
85-
%r|SELECT @@version| << %r|SELECT @@TRANCOUNT| << %r{(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION}
85+
self.ignored_sql = [
86+
%r|SELECT SCOPE_IDENTITY|, %r{INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS)},
87+
%r|SELECT @@version|, %r|SELECT @@TRANCOUNT|, %r{(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION}
88+
]
8689
end
8790
end
8891

test/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
default_connection: dblib
2+
3+
default_connection_info: &default_connection_info
4+
adapter: sqlserver
5+
mode: <%= ENV['ARCONN'] %>
6+
host: <%= ENV['ACTIVERECORD_UNITTEST_DATASERVER'] || 'localhost' %>
7+
database: activerecord_unittest
8+
username: <%= ENV['ACTIVERECORD_UNITTEST_USER'] || 'rails' %>
9+
password: <%= ENV['ACTIVERECORD_UNITTEST_PASS'] || '' %>
10+
azure: <%= !ENV['ACTIVERECORD_UNITTEST_AZURE'].nil? %>
11+
12+
connections:
13+
14+
dblib:
15+
arunit:
16+
<<: *default_connection_info
17+
appname: SQLServerAdptrUnit
18+
arunit2:
19+
<<: *default_connection_info
20+
database: activerecord_unittest2
21+
appname: SQLServerAdptrUnit2
22+
23+
odbc:
24+
arunit:
25+
<<: *default_connection_info
26+
dsn: <%= ENV['ACTIVERECORD_UNITTEST2_DSN'] || 'activerecord_unittest' %>
27+
arunit2:
28+
<<: *default_connection_info
29+
database: activerecord_unittest2
30+
dsn: <%= ENV['ACTIVERECORD_UNITTEST2_DSN'] || 'activerecord_unittest2' %>
31+

test/connections/dblib/connection_name.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/connections/odbc/connection_name.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/support/config.rb

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)