Sha256: 74b649b96935e0ad6bf98921abff15869be725607197565e9b592e942b668ac0
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' require 'support/time_machine/structure' describe ChronoModel::TimeMachine do include ChronoTest::TimeMachine::Helpers # Set up database structure # adapter.create_table 'defoos', :temporal => true do |t| t.string :name t.boolean :active end class ::Defoo < ActiveRecord::Base include ChronoModel::TimeMachine default_scope proc { where(:active => true) } end active = ts_eval { Defoo.create! :name => 'active 1', :active => true } ts_eval(active) { update_attributes! :name => 'active 2' } hidden = ts_eval { Defoo.create! :name => 'hidden 1', :active => false } ts_eval(hidden) { update_attributes! :name => 'hidden 2' } describe 'it honors default_scopes' do it { expect(Defoo.as_of(active.ts[0]).map(&:name)).to eq ['active 1'] } it { expect(Defoo.as_of(active.ts[1]).map(&:name)).to eq ['active 2'] } it { expect(Defoo.as_of(hidden.ts[0]).map(&:name)).to eq ['active 2'] } it { expect(Defoo.as_of(hidden.ts[1]).map(&:name)).to eq ['active 2'] } it { expect(Defoo.unscoped.as_of(active.ts[0]).map(&:name)).to eq ['active 1'] } it { expect(Defoo.unscoped.as_of(active.ts[1]).map(&:name)).to eq ['active 2'] } it { expect(Defoo.unscoped.as_of(hidden.ts[0]).map(&:name)).to eq ['active 2', 'hidden 1'] } it { expect(Defoo.unscoped.as_of(hidden.ts[1]).map(&:name)).to eq ['active 2', 'hidden 2'] } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chrono_model-1.2.2 | spec/chrono_model/time_machine/default_scope_spec.rb |
chrono_model-1.2.1 | spec/chrono_model/time_machine/default_scope_spec.rb |