From 3950c8b30af2d8f81a672f5eea39d26f686d625b Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 10 Feb 2014 00:17:28 +0100 Subject: [PATCH] Fix for broken filters where `this` context was lost. fixes #2157 - Change tests to only check for existance - Properly bind helpers/filters to their instance --- core/server/apps/proxy.js | 10 +++++----- core/test/unit/apps_spec.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/server/apps/proxy.js b/core/server/apps/proxy.js index 922abc4710..29afb2402f 100644 --- a/core/server/apps/proxy.js +++ b/core/server/apps/proxy.js @@ -6,12 +6,12 @@ var _ = require('lodash'), var proxy = { filters: { - register: filters.registerFilter, - unregister: filters.unregisterFilter + register: filters.registerFilter.bind(filters), + unregister: filters.unregisterFilter.bind(filters) }, helpers: { - register: helpers.registerThemeHelper, - registerAsync: helpers.registerAsyncThemeHelper + register: helpers.registerThemeHelper.bind(helpers), + registerAsync: helpers.registerAsyncThemeHelper.bind(helpers) }, api: { posts: _.pick(api.posts, 'browse', 'read'), @@ -21,4 +21,4 @@ var proxy = { } }; -module.exports = proxy; \ No newline at end of file +module.exports = proxy; diff --git a/core/test/unit/apps_spec.js b/core/test/unit/apps_spec.js index 9cbd98deea..ab4b16aaea 100644 --- a/core/test/unit/apps_spec.js +++ b/core/test/unit/apps_spec.js @@ -56,12 +56,12 @@ describe('Apps', function () { describe('Proxy', function () { it('creates a ghost proxy', function () { should.exist(appProxy.filters); - appProxy.filters.register.should.equal(filters.registerFilter); - appProxy.filters.unregister.should.equal(filters.unregisterFilter); + should.exist(appProxy.filters.register); + should.exist(appProxy.filters.unregister); should.exist(appProxy.helpers); - appProxy.helpers.register.should.equal(helpers.registerThemeHelper); - appProxy.helpers.registerAsync.should.equal(helpers.registerAsyncThemeHelper); + should.exist(appProxy.helpers.register); + should.exist(appProxy.helpers.registerAsync); should.exist(appProxy.api); @@ -189,4 +189,4 @@ describe('Apps', function () { }); }); }); -}); \ No newline at end of file +});