Permalink
Browse files

Add a spec to ensure that invalid versions can be expired too

  • Loading branch information...
1 parent a610a91 commit de3bc44422f1c7353c6cb0afff942e04886ca1f8 @JosephHalter JosephHalter committed May 2, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 spec/bitemporal_date_spec.rb
@@ -298,6 +298,20 @@
| King Size | 94 | 2009-11-29 | | 2009-11-29 | MAX DATE | true |
}
end
+ it "can expire invalid versions" do
+ master = @master_class.new.update_attributes name: "Single Standard", price: 98
+ master.current_version.price = nil
+ master.current_version.should_not be_valid
+ master.current_version.save validate: false
+ Timecop.freeze Date.today+1
+ master.update_attributes price: 94, partial_update: true
+ master.should have_versions %Q{
+ | name | price | created_at | expired_at | valid_from | valid_to | current |
+ | Single Standard | | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
+ | Single Standard | | 2009-11-29 | | 2009-11-28 | 2009-11-29 | |
+ | Single Standard | 94 | 2009-11-29 | | 2009-11-29 | MAX DATE | true |
+ }
+ end
it "allows eager loading with conditions on current version" do
master = @master_class.new
master.update_attributes name: "Single Standard", price: 98

0 comments on commit de3bc44

Please sign in to comment.