-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make this.userId available to before/after find/findOne within server…
… publish
- Loading branch information
Showing
5 changed files
with
241 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var Collection = new Meteor.Collection("tests_publish"); | ||
|
||
if (Meteor.isServer) { | ||
(function () { | ||
|
||
Meteor.methods({ | ||
tests_publish_reset: function () { | ||
Collection.remove({}); | ||
Collection.insert({pass: false}); | ||
Collection.insert({pass: true}); | ||
} | ||
}); | ||
|
||
Meteor.call("tests_publish_reset", function () { | ||
Meteor.publish("tests_publish", function () { | ||
return Collection.find({pass: (this.userId === Meteor.__collection_hooks_publish_userId)}); | ||
}); | ||
}); | ||
|
||
})(); | ||
} | ||
|
||
if (Meteor.isClient) { | ||
(function () { | ||
|
||
Tinytest.addAsync("global publish_userId available within publish", function (test, next) { | ||
function run() { | ||
Meteor.call("tests_publish_reset", function (err, result) { | ||
test.equal(!!err, false); | ||
|
||
var handle = Meteor.subscribe("tests_publish", function () { | ||
var doc = Collection.findOne({pass: true}); | ||
if (doc) { | ||
next(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
if (Meteor.userId()) { | ||
Meteor._debug("already logged in -- running tests"); | ||
run(); | ||
} else { | ||
Meteor._debug("logging in to run tests"); | ||
Meteor.insecureUserLogin("tests_publish", run); | ||
} | ||
}); | ||
|
||
})(); | ||
} |
Oops, something went wrong.