Sha256: 9f91a43673dc4bf0a35d7a69a67d1d189f64bd2ec6abf2333ffc3a42e8261c76
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
require File.expand_path('../test_helper', __FILE__) describe "AsNewSan" do include DBSetupAndTeardownHelper it "should really create a record for a `new` object with `as_new` set to `true`" do lambda { BaconFlavour.as_new(:name => 'chunky') }.should.differ('BaconFlavour.count', +1) BaconFlavour.find_by_name('chunky').as_new.should.be true end it "should garbage collect any record which has been in the db for a specific period" do old_record = BaconFlavour.as_new(:name => 'banana', :created_at => (Time.now - 1.week - 1)) new_record = BaconFlavour.as_new(:name => 'smoked') lambda { BaconFlavour.collect_garbage! }.should.differ('BaconFlavour.count', -1) end it "should be possible to do a `find` without matching any `as_new` records" do as_new_record = BaconFlavour.as_new(:name => 'smells as new') not_as_new_record = BaconFlavour.create(:name => 'does not smell at all') BaconFlavour.find(:all).should == [as_new_record, not_as_new_record] BaconFlavour.find_without_as_new(:all).should == [not_as_new_record] end it "should set `as_new` records to `false` on update" do record = BaconFlavour.as_new(:name => 'ice cream') record.as_new_record?.should.be true record.update_attribute(:name, 'that is right, bacon ice cream') record.as_new_record?.should.be false end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Fingertips-as_new-san-0.1.0 | test/as_new_san_test.rb |
Fingertips-as_new-san-0.1.1 | test/as_new_san_test.rb |