-
Notifications
You must be signed in to change notification settings - Fork 563
/
Copy pathuuid_test_sqlserver.rb
47 lines (38 loc) · 1.48 KB
/
uuid_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# encoding: UTF-8
require 'cases/helper_sqlserver'
class SQLServerUuidTest < ActiveRecord::TestCase
let(:acceptable_uuid) { ActiveRecord::ConnectionAdapters::SQLServer::Type::Uuid::ACCEPTABLE_UUID }
it 'has a uuid primary key' do
_(SSTestUuid.columns_hash['id'].type).must_equal :uuid
assert SSTestUuid.primary_key
end
it 'can create with a new pk' do
obj = SSTestUuid.create!
_(obj.id).must_be :present?
_(obj.id).must_match acceptable_uuid
end
it 'can create other uuid column on reload' do
obj = SSTestUuid.create!
obj.reload
_(obj.other_uuid).must_match acceptable_uuid
end
it 'can find uuid pk via connection' do
_(connection.primary_key(SSTestUuid.table_name)).must_equal 'id'
end
it 'changing column default' do
table_name = SSTestUuid.table_name
connection.add_column table_name, :thingy, :uuid, null: false, default: "NEWSEQUENTIALID()"
SSTestUuid.reset_column_information
column = SSTestUuid.columns_hash['thingy']
_(column.default_function).must_equal "newsequentialid()"
# Now to a different function.
connection.change_column table_name, :thingy, :uuid, null: false, default: "NEWID()"
SSTestUuid.reset_column_information
column = SSTestUuid.columns_hash['thingy']
_(column.default_function).must_equal "newid()"
end
it 'can insert even when use_output_inserted to false ' do
obj = with_use_output_inserted_disabled { SSTestUuid.create!(name: "😢") }
_(obj.id).must_be :nil?
end
end