Sha256: 9c0c316b9defb63db91a6416b7daf432e4228613420e29e347bb8704edf9c393

Contents?: true

Size: 893 Bytes

Versions: 14

Compression:

Stored size: 893 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(:find).at_least(1).with(@post.id).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

14 entries across 14 versions & 1 rubygems

Version Path
mongoid-0.7.7 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.6 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.5 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.4 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.3 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.2 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.1 spec/unit/mongoid/versioning_spec.rb
mongoid-0.7.0 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.10 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.9 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.8 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.7 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.6 spec/unit/mongoid/versioning_spec.rb
mongoid-0.6.5 spec/unit/mongoid/versioning_spec.rb