From d5c7ef0f7886afdfeb6d78b7e320ba2bfe5c77ba Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 7 Feb 2014 12:14:32 -0800 Subject: revert: refactor(mocks): simplify the `inject` implementation This reverts commit 64d58a5b5292046adf8b28928950858ab3895fcc. For some weird reason this is causing regressions at Google. I'm not sure why and I'm running out of time to investigate, so I'm taking a safe route here and reverting the commit since it's just a refactoring. --- src/ngMock/angular-mocks.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ngMock/angular-mocks.js') diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 1be07a24..6b8868f7 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -2095,7 +2095,7 @@ if(window.jasmine || window.mocha) { window.inject = angular.mock.inject = function() { var blockFns = Array.prototype.slice.call(arguments, 0); var errorForStack = new Error('Declaration Location'); - return isSpecRunning() ? workFn() : workFn; + return isSpecRunning() ? workFn.call(currentSpec) : workFn; ///////////////////// function workFn() { var modules = currentSpec.$modules || []; @@ -2108,8 +2108,9 @@ if(window.jasmine || window.mocha) { } for(var i = 0, ii = blockFns.length; i < ii; i++) { try { - // jasmine sets this to be the current spec, so we are mimicing that - injector.invoke(blockFns[i] || angular.noop, currentSpec); + /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */ + injector.invoke(blockFns[i] || angular.noop, this); + /* jshint +W040 */ } catch (e) { if (e.stack && errorForStack) { throw new ErrorAddingDeclarationLocationStack(e, errorForStack); -- cgit v1.2.3