-
Notifications
You must be signed in to change notification settings - Fork 563
/
Copy pathtrigger_test_sqlserver.rb
30 lines (26 loc) · 1.23 KB
/
trigger_test_sqlserver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# encoding: UTF-8
require 'cases/helper_sqlserver'
class SQLServerTriggerTest < ActiveRecord::TestCase
after { exclude_output_inserted_table_names.clear }
let(:exclude_output_inserted_table_names) do
ActiveRecord::ConnectionAdapters::SQLServerAdapter.exclude_output_inserted_table_names
end
it 'can insert into a table with output inserted - with a true setting for table name' do
exclude_output_inserted_table_names['sst_table_with_trigger'] = true
assert SSTestTriggerHistory.all.empty?
obj = SSTestTrigger.create! event_name: 'test trigger'
['Fixnum', 'Integer'].must_include obj.id.class.name
obj.event_name.must_equal 'test trigger'
obj.id.must_be :present?
obj.id.to_s.must_equal SSTestTriggerHistory.first.id_source
end
it 'can insert into a table with output inserted - with a uniqueidentifier value' do
exclude_output_inserted_table_names['sst_table_with_uuid_trigger'] = 'uniqueidentifier'
assert SSTestTriggerHistory.all.empty?
obj = SSTestTriggerUuid.create! event_name: 'test uuid trigger'
obj.id.class.name.must_equal 'String'
obj.event_name.must_equal 'test uuid trigger'
obj.id.must_be :present?
obj.id.to_s.must_equal SSTestTriggerHistory.first.id_source
end
end