Sha256: 59e41ae18007049cbf17d8bb3fae7e9a1d2e8be9821f44f5f1e413fb2bca93e4
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'spec_helper' require 'support/helpers' describe 'models with STI' do include ChronoTest::Helpers::TimeMachine adapter.create_table 'animals', temporal: true do |t| t.string :type end class ::Animal < ActiveRecord::Base include ChronoModel::TimeMachine end class ::Dog < Animal end class ::Goat < Animal end describe 'it generates the right queries' do before do Dog.create! @later = Time.new Goat.create! end after do tables = ['temporal.animals', 'history.animals'] ActiveRecord::Base.connection.execute "truncate #{tables.join(', ')} cascade" end specify "select" do expect(Animal.first).to_not be_nil expect(Animal.as_of(@later).first).to_not be_nil end specify "count" do expect(Animal.count).to eq(2) expect(Animal.as_of(@later).count).to eq(1) expect(Dog.count).to eq(1) expect(Dog.as_of(@later).count).to eq(1) expect(Goat.count).to eq(1) expect(Goat.as_of(@later).count).to eq(0) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chrono_model-1.2.0 | spec/chrono_model/adapter/sti_bug_spec.rb |