Sha256: cf0e34788f79675e59049f2dcd2fd0f6331664d6e062be24175475d5675be20f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-sqlserver-adapter-5.2.1 test/cases/trigger_test_sqlserver.rb