Commit 78c6023fa1c1c046a503e3854255f574d12bce98
- Date: Wed Apr 30 03:57:25 +0000 2008
- Committer: Yurii Rashkovskii (yrashk@gmail.com)
- Author: Yurii Rashkovskii (yrashk@gmail.com)
- Commit SHA1: 78c6023fa1c1c046a503e3854255f574d12bce98
- Tree SHA1: 7fdbbff7dca9bf9a8e38c480103017154a81582d
Transaction#head_version is implemented
Commit diff
| |   |
| 26 | 26 | storage.find(uuid,version,opts.merge(:store => self)) |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | def head_version(uuid) |
| 30 | storage.head_version(uuid,{ :store => self }) |
| 31 | end |
| 32 | |
| 29 | 33 | def save!(doc) |
| 30 | 34 | @timestamp = @timestamp.next |
| 31 | 35 | storage.save!(doc,@timestamp) |
| toggle raw diff |
--- a/lib/strokedb/transaction.rb
+++ b/lib/strokedb/transaction.rb
@@ -26,6 +26,10 @@ module StrokeDB
storage.find(uuid,version,opts.merge(:store => self))
end
+ def head_version(uuid)
+ storage.head_version(uuid,{ :store => self })
+ end
+
def save!(doc)
@timestamp = @timestamp.next
storage.save!(doc,@timestamp) |
| |   |
| 47 | 47 | end |
| 48 | 48 | Document.find(@doc.uuid).should be_nil |
| 49 | 49 | end |
| 50 | |
| 51 | it "should see its own head version of the document" do |
| 52 | @doc = Document.create! |
| 53 | @txn.execute do |txn| |
| 54 | @doc.update_slots! :new_version => 'yes' |
| 55 | @doc.store.head_version(@doc.uuid).should == @doc.version |
| 56 | end |
| 57 | @doc.store.head_version(@doc.uuid).should == @doc.versions.previous.version |
| 58 | end |
| 50 | 59 | |
| 51 | 60 | it "should be able to commit transaction" do |
| 52 | 61 | @txn.execute do |txn| |
| toggle raw diff |
--- a/spec/lib/strokedb/stores/transaction_spec.rb
+++ b/spec/lib/strokedb/stores/transaction_spec.rb
@@ -47,6 +47,15 @@ describe 'Transaction', :shared => true do
end
Document.find(@doc.uuid).should be_nil
end
+
+ it "should see its own head version of the document" do
+ @doc = Document.create!
+ @txn.execute do |txn|
+ @doc.update_slots! :new_version => 'yes'
+ @doc.store.head_version(@doc.uuid).should == @doc.version
+ end
+ @doc.store.head_version(@doc.uuid).should == @doc.versions.previous.version
+ end
it "should be able to commit transaction" do
@txn.execute do |txn| |