Skip to content

Commit 34e5852

Browse files
authored
Add assertions to tests missing any assertions (#1193)
1 parent 331ca6b commit 34e5852

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

test/cases/adapter_test_sqlserver.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
289289
end
290290

291291
it "ALLOW deletion of referenced parent using #disable_referential_integrity block" do
292-
SSTestHasPk.lease_connection.disable_referential_integrity { @parent.destroy }
292+
assert_difference("SSTestHasPk.count", -1) do
293+
SSTestHasPk.lease_connection.disable_referential_integrity { @parent.destroy }
294+
end
293295
end
294296

295297
it "again NOT ALLOW deletion of referenced parent after #disable_referential_integrity block" do
@@ -549,11 +551,15 @@ def test_doesnt_error_when_a_select_query_is_called_while_preventing_writes
549551

550552
describe 'table is in non-dbo schema' do
551553
it "records can be created successfully" do
552-
Alien.create!(name: 'Trisolarans')
554+
assert_difference("Alien.count", 1) do
555+
Alien.create!(name: 'Trisolarans')
556+
end
553557
end
554558

555559
it 'records can be inserted using SQL' do
556-
Alien.lease_connection.exec_insert("insert into [test].[aliens] (id, name) VALUES(1, 'Trisolarans'), (2, 'Xenomorph')")
560+
assert_difference("Alien.count", 2) do
561+
Alien.lease_connection.exec_insert("insert into [test].[aliens] (id, name) VALUES(1, 'Trisolarans'), (2, 'Xenomorph')")
562+
end
557563
end
558564
end
559565

test/cases/disconnected_test_sqlserver.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def setup
1919
test "execute procedure after disconnect reconnects" do
2020
@connection.execute_procedure :sp_tables, "sst_datatypes"
2121
@connection.disconnect!
22-
@connection.execute_procedure :sp_tables, "sst_datatypes"
22+
23+
assert_nothing_raised do
24+
@connection.execute_procedure :sp_tables, "sst_datatypes"
25+
end
2326
end
2427

2528
test "execute query after disconnect reconnects" do
@@ -31,6 +34,9 @@ def setup
3134

3235
@connection.exec_query sql, "TEST", binds
3336
@connection.disconnect!
34-
@connection.exec_query sql, "TEST", binds
37+
38+
assert_nothing_raised do
39+
@connection.exec_query sql, "TEST", binds
40+
end
3541
end
3642
end

test/cases/index_test_sqlserver.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class IndexTestSQLServer < ActiveRecord::TestCase
4141
end
4242

4343
it "add index with expression" do
44-
connection.execute "ALTER TABLE [testings] ADD [first_name_upper] AS UPPER([first_name])"
45-
connection.add_index "testings", "first_name_upper"
44+
assert_nothing_raised do
45+
connection.execute "ALTER TABLE [testings] ADD [first_name_upper] AS UPPER([first_name])"
46+
connection.add_index "testings", "first_name_upper"
47+
end
4648
end
4749
end

test/cases/scratchpad_test_sqlserver.rb

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

test/cases/specific_schema_test_sqlserver.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ class SpecificSchemaTestSQLServer < ActiveRecord::TestCase
66
after { SSTestEdgeSchema.delete_all }
77

88
it "handle dollar symbols" do
9-
SSTestDollarTableName.create!
10-
SSTestDollarTableName.limit(20).offset(1)
9+
assert_difference("SSTestDollarTableName.count", 1) do
10+
SSTestDollarTableName.create!
11+
end
12+
assert_nothing_raised do
13+
SSTestDollarTableName.limit(20).offset(1)
14+
end
1115
end
1216

1317
it "models can use tinyint pk tables" do

0 commit comments

Comments
 (0)