Sha256: 0da0976c9521ba488fc3c6a609aee7dec3c15c3cf0bdf2e6096186dfdec8864f

Contents?: true

Size: 555 Bytes

Versions: 4

Compression:

Stored size: 555 Bytes

Contents

require 'mongo_db/spec_helper'

describe "MongoMapper micelaneous" do
  before do
    connection = Mongo::Connection.new.db('test')
    @collection = connection.collection('test')
  end
  
  it "upsert should update" do
    id = @collection.save count: 2
    @collection.upsert!({_id: id}, :$inc => {count: 1})
    @collection.find(_id: id).first['count'].should == 3
  end

  it "upsert should set" do
    id = @collection.save({})
    @collection.upsert!({_id: id}, :$inc => {count: 1})
    @collection.find(_id: id).first['count'].should == 1
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper_ext-0.2.7 spec/mongo_db/upsert_spec.rb
mongo_mapper_ext-0.2.6 spec/mongo_db/upsert_spec.rb
mongo_mapper_ext-0.2.5 spec/mongo_db/upsert_spec.rb
mongo_mapper_ext-0.2.4 spec/mongo_db/upsert_spec.rb