Sha256: 6758854efc7603deac0d050e6f3046bcb34a15da398b81b480b80633491a5dd3

Contents?: true

Size: 936 Bytes

Versions: 16

Compression:

Stored size: 936 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "/../../spec_helper.rb"))

describe Mongoid::Versioning do

  describe "#version" do

    before do
      @post = Post.new
    end

    it "defaults to 1" do
      @post.version.should == 1
    end

    context "when document is saved" do

      before do
        @post.title = "New"
        @version = Post.new(:title => "Test")
        Post.expects(:first).at_least(1).with(:conditions => { :_id => @post.id, :version => 1 }).returns(@version)
        @post.revise
      end

      it "increments the version" do
        @post.version.should == 2
      end

      it "adds a snapshot of the document to the versions" do
        @post.title.should == "New"
        @post.version.should == 2
        @post.versions.size.should == 1
        version = @post.versions.first
        version.title.should == "Test"
        version.version.should == 1
      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mongoid-0.9.2 spec/unit/mongoid/versioning_spec.rb
mongoid-0.9.1 spec/unit/mongoid/versioning_spec.rb
mongoid-0.9.0 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.10 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.9 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.8 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.7 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.6 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.5 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.4 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.3 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.2 spec/unit/mongoid/versioning_spec.rb
mongoid-0.8.1 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.10 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.9 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.8 spec/unit/mongoid/versioning_spec.rb