mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Improve test for subscriptions on userid change
The test service's subscriptions now have some data overlap for different users, verify that we indeed diff the query results correctly.
This commit is contained in:
committed by
Nick Martin
parent
3a26b18a3f
commit
4d257aa545
@@ -100,15 +100,16 @@ objectsWithUsers = new Meteor.Collection("objectsWithUsers");
|
||||
|
||||
if (Meteor.is_server) {
|
||||
objectsWithUsers.remove({});
|
||||
objectsWithUsers.insert({name: "owned by none", ownerUserId: null});
|
||||
objectsWithUsers.insert({name: "owned by one - a", ownerUserId: 1});
|
||||
objectsWithUsers.insert({name: "owned by one - b", ownerUserId: 1});
|
||||
objectsWithUsers.insert({name: "owned by two - a", ownerUserId: 2});
|
||||
objectsWithUsers.insert({name: "owned by two - b", ownerUserId: 2});
|
||||
objectsWithUsers.insert({name: "owned by two - c", ownerUserId: 2});
|
||||
objectsWithUsers.insert({name: "owned by none", ownerUserIds: [null]});
|
||||
objectsWithUsers.insert({name: "owned by one - a", ownerUserIds: [1]});
|
||||
objectsWithUsers.insert({name: "owned by one/two - a", ownerUserIds: [1, 2]});
|
||||
objectsWithUsers.insert({name: "owned by one/two - b", ownerUserIds: [1, 2]});
|
||||
objectsWithUsers.insert({name: "owned by two - a", ownerUserIds: [2]});
|
||||
objectsWithUsers.insert({name: "owned by two - b", ownerUserIds: [2]});
|
||||
|
||||
Meteor.publish("objectsWithUsers", function() {
|
||||
return objectsWithUsers.find({ownerUserId: this.userId()});
|
||||
return objectsWithUsers.find({ownerUserIds: this.userId()},
|
||||
{fields: {ownerUserIds: 0}});
|
||||
});
|
||||
|
||||
userIdWhenStopped = null;
|
||||
|
||||
@@ -327,8 +327,9 @@ testAsyncMulti("livedata - changing userid reruns subscriptions without flapping
|
||||
testSetAndUnset([
|
||||
{unset: true},
|
||||
{set: "owned by one - a"},
|
||||
{set: "owned by one - b"}]);
|
||||
test.equal(objectsWithUsers.find().count(), 2);
|
||||
{set: "owned by one/two - a"},
|
||||
{set: "owned by one/two - b"}]);
|
||||
test.equal(objectsWithUsers.find().count(), 3);
|
||||
Meteor.defer(sendSecondSetUserId);
|
||||
});
|
||||
|
||||
@@ -339,12 +340,10 @@ testAsyncMulti("livedata - changing userid reruns subscriptions without flapping
|
||||
|
||||
var afterSecondSetUserId = expect(function() {
|
||||
testSetAndUnset([
|
||||
{unset: true},
|
||||
{unset: true},
|
||||
{set: "owned by two - a"},
|
||||
{set: "owned by two - b"},
|
||||
{set: "owned by two - c"}]);
|
||||
test.equal(objectsWithUsers.find().count(), 3);
|
||||
{set: "owned by two - b"}]);
|
||||
test.equal(objectsWithUsers.find().count(), 4);
|
||||
Meteor.defer(sendThirdSetUserId);
|
||||
});
|
||||
|
||||
@@ -357,7 +356,7 @@ testAsyncMulti("livedata - changing userid reruns subscriptions without flapping
|
||||
// Nothing should have been sent since the results of the
|
||||
// query are the same ("don't flap data on the wire")
|
||||
testSetAndUnset([]);
|
||||
test.equal(objectsWithUsers.find().count(), 3);
|
||||
test.equal(objectsWithUsers.find().count(), 4);
|
||||
undoEavesdrop();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user