Sha256: 46a8fe30131dadca2f8972176db2a1c57526656942214737069cebfb893353fd

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

# 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
    # Type::Uuid::ACCEPTABLE_UUID
    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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
activerecord-sqlserver-adapter-4.2.18 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.17 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.16 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter_new-4.2.15 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.15 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.13 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.12 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.11 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.10 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.9 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.8 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.6 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.5 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.4 test/cases/uuid_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.3 test/cases/uuid_test_sqlserver.rb