0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Ensure filters get default priority if priority is null

- null priority should be set to the default
- second part to 86619cb087
This commit is contained in:
Hannah Wolfe 2014-02-10 13:03:53 +00:00
parent b04c0bb83c
commit d790a504a3
2 changed files with 18 additions and 0 deletions

View file

@ -28,6 +28,11 @@ Filters.prototype.registerFilter = function (name, priority, fn) {
// Curry the priority optional parameter to a default of 5
if (_.isFunction(priority)) {
fn = priority;
priority = null;
}
// Null priority should be set to default
if (priority === null) {
priority = defaults.filterPriority;
}

View file

@ -49,6 +49,19 @@ describe("Filters", function () {
filters.filterCallbacks[filterName][defaultPriority].should.include(testFilterHandler);
});
it("can register filters with priority null with default priority", function () {
var filterName = 'test',
defaultPriority = 5,
testFilterHandler = sandbox.spy();
filters.registerFilter(filterName, null, testFilterHandler);
should.exist(filters.filterCallbacks[filterName]);
should.exist(filters.filterCallbacks[filterName][defaultPriority]);
filters.filterCallbacks[filterName][defaultPriority].should.include(testFilterHandler);
});
it("executes filters in priority order", function (done) {
var filterName = 'testpriority',
testFilterHandler1 = sandbox.spy(),