File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require "cases/helper_sqlserver"
4
- require "models/topic"
5
- require "models/task"
6
- require "models/post"
7
- require "models/subscriber"
8
- require "models/minimalistic"
9
- require "models/college"
4
+ require "models/dog"
5
+ require "models/other_dog"
10
6
11
7
class TempTestSQLServer < ActiveRecord ::TestCase
12
8
# it "assert true" do
13
9
# assert true
14
10
# end
15
11
16
12
it "insert from one schema to another using raw SQL" do
17
- arunit_connection = Topic . lease_connection
18
- arunit2_connection = College . lease_connection
13
+ arunit_connection = Dog . lease_connection
14
+ arunit2_connection = OtherDog . lease_connection
19
15
20
16
arunit_database = arunit_connection . pool . db_config . database
21
17
arunit2_database = arunit2_connection . pool . db_config . database
@@ -24,8 +20,16 @@ class TempTestSQLServer < ActiveRecord::TestCase
24
20
INSERT INTO #{ arunit2_database } .dbo.dogs(id) SELECT id FROM #{ arunit_database } .dbo.dogs
25
21
SQL
26
22
27
- assert_nothing_raised do
28
- arunit_connection . execute ( sql )
23
+ assert Dog . count , 1
24
+ assert OtherDog . count , 0
25
+
26
+ arunit_connection . transaction do
27
+ assert_nothing_raised do
28
+ arunit_connection . execute ( sql )
29
+ end
29
30
end
31
+
32
+ assert Dog . count , 1
33
+ assert OtherDog . count , 1
30
34
end
31
35
end
You can’t perform that action at this time.
0 commit comments