Sha256: 250e1c4dc66559d794d5a5a152d29e05553c94f3264692b340b292339823db84

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'support/adapter/structure'

describe ChronoModel::Adapter do
  include ChronoTest::Adapter::Helpers
  include ChronoTest::Adapter::Structure

  before :all do
    adapter.create_table :meetings do |t|
      t.string :name
      t.tsrange :interval
    end
  end

  after :all do
    adapter.drop_table :meetings
  end

  describe '.add_temporal_indexes' do
    before do
      adapter.add_temporal_indexes :meetings, :interval
    end

    it { expect(adapter.indexes(:meetings).map(&:name)).to eq [
      'index_meetings_temporal_on_interval',
      'index_meetings_temporal_on_lower_interval',
      'index_meetings_temporal_on_upper_interval'
    ] }

    after do
      adapter.remove_temporal_indexes :meetings, :interval
    end
  end

  describe '.remove_temporal_indexes' do
    before :all do
      adapter.add_temporal_indexes :meetings, :interval
    end

    before do
      adapter.remove_temporal_indexes :meetings, :interval
    end

    it { expect(adapter.indexes(:meetings)).to be_empty }
  end

  describe '.add_timeline_consistency_constraint' do
    before do
      adapter.add_timeline_consistency_constraint(:meetings, :interval)
    end

    it { expect(adapter.indexes(:meetings).map(&:name)).to eq [
      'meetings_timeline_consistency'
    ] }

    after do
      adapter.remove_timeline_consistency_constraint(:meetings)
    end
  end

  describe '.remove_timeline_consistency_constraint' do
    before :all do
      adapter.add_timeline_consistency_constraint :meetings, :interval
    end

    before do
      adapter.remove_timeline_consistency_constraint(:meetings)
    end

    it { expect(adapter.indexes(:meetings)).to be_empty }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chrono_model-1.2.2 spec/chrono_model/adapter/indexes_spec.rb
chrono_model-1.2.1 spec/chrono_model/adapter/indexes_spec.rb