Sha256: ce9de8a43f5ec302d2298c3698309fbc374b1f373c64645dcccfe2fb2456b8c8

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe TemporalTables::TemporalAdapter do
  describe '#remove_temporal_table' do
    it 'correctly removes history table, functions and triggers' do
      skip 'mysql has no functions' if adapter_name == 'mysql'

      expect do
        ActiveRecord::Schema.define { remove_temporal_table :people }
      end.to change { table_exists?('people_h') }.from(true).to(false)
         .and change { function_exists?('people_ai()') }.from(true).to(false)
         .and change { function_exists?('people_au()') }.from(true).to(false)
         .and change { function_exists?('people_ad()') }.from(true).to(false)
         .and change { trigger_exists?('people_ai') }.from(true).to(false)
         .and change { trigger_exists?('people_au') }.from(true).to(false)
         .and change { trigger_exists?('people_ad') }.from(true).to(false)
    end

    it 'correctly removes history table and triggers' do
      skip 'other adapters than mysql have functions, too' if adapter_name != 'mysql'

      expect do
        ActiveRecord::Schema.define { remove_temporal_table :people }
      end.to change { table_exists?('people_h') }.from(true).to(false)
         .and change { trigger_exists?('people_ai') }.from(true).to(false)
         .and change { trigger_exists?('people_au') }.from(true).to(false)
         .and change { trigger_exists?('people_ad') }.from(true).to(false)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
temporal_tables-3.0.2 spec/temporal_tables/temporal_adapter_spec.rb