Sha256: b1f5add204ebac88ca37246e94b12ea779b66c762be1f6e81fc15f08c1a8fca9

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 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
    skip 'OUTPUT.inserted not supported at this point' if defined? JRUBY_VERSION
    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

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-jdbcsqlserver-adapter-51.1.0 test/cases/trigger_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.1 test/cases/trigger_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.0 test/cases/trigger_test_sqlserver.rb