mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Tests for update/upsert with $push/$each.
Test adapted by mcbain's test from #1492.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Fail explicitly when publishing non-cursors.
|
||||
|
||||
* Implement `$each`, `$sort`, and `$slice` options for minimongo's `$push`
|
||||
modifier.
|
||||
modifier. #1492
|
||||
|
||||
* Increase the maximum size spiderable will return for a page from 200kB
|
||||
to 5MB.
|
||||
@@ -11,6 +11,8 @@
|
||||
* Upgraded dependencies:
|
||||
* SockJS server from 0.3.7 to 0.3.8
|
||||
|
||||
Patches contributed by GitHub user mcbain.
|
||||
|
||||
|
||||
## v0.6.6.1
|
||||
|
||||
|
||||
@@ -1815,3 +1815,55 @@ Tinytest.addAsync("mongo-livedata - local collection with null connection, w/o c
|
||||
test.equal(coll1.findOne(doc)._id, docId);
|
||||
onComplete();
|
||||
});
|
||||
|
||||
Tinytest.add("mongo-livedata - update handles $push with $each correctly", function (test) {
|
||||
var collection = new Meteor.Collection(Random.id());
|
||||
|
||||
var id = collection.insert({name: 'jens', elements: ['X', 'Y']});
|
||||
|
||||
var result = collection.update(id, {
|
||||
$push: {
|
||||
elements: {
|
||||
$each: ['A', 'B', 'C'],
|
||||
$slice: -4
|
||||
}}});
|
||||
|
||||
test.equal(collection.findOne(id), {
|
||||
_id: id,
|
||||
name: 'jens',
|
||||
elements: ['Y', 'A', 'B', 'C']
|
||||
});
|
||||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Tinytest.add("mongo-livedata - upsert handles $push with $each correctly", function (test) {
|
||||
var collection = new Meteor.Collection(Random.id());
|
||||
|
||||
var result = collection.upsert(
|
||||
{name: 'jens'},
|
||||
{$push: {
|
||||
elements: {
|
||||
$each: ['A', 'B', 'C'],
|
||||
$slice: -4
|
||||
}}});
|
||||
|
||||
test.equal(collection.findOne(result.insertedId),
|
||||
{_id: result.insertedId,
|
||||
name: 'jens',
|
||||
elements: ['A', 'B', 'C']});
|
||||
|
||||
var id = collection.insert({name: "david", elements: ['X', 'Y']});
|
||||
result = collection.upsert(
|
||||
{name: 'david'},
|
||||
{$push: {
|
||||
elements: {
|
||||
$each: ['A', 'B', 'C'],
|
||||
$slice: -4
|
||||
}}});
|
||||
|
||||
test.equal(collection.findOne(id),
|
||||
{_id: id,
|
||||
name: 'david',
|
||||
elements: ['Y', 'A', 'B', 'C']});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user