diff --git a/.travis.yml b/.travis.yml index dbfe28541d6e..d9f02d01b9fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,3 +26,4 @@ script: after_script: - ./scripts/travis/print_logs.sh + diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 19f0ac9d7ed9..0058a8ec1dfe 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -2125,7 +2125,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 || []; diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index fb602adc2ace..e5f67a7ebc48 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -864,6 +864,25 @@ describe('ngMock', function() { }); + describe('this', function() { + + it('should set `this` to be the jasmine context', inject(function() { + expect(this instanceof jasmine.Spec).toBe(true); + })); + + it('should set `this` to be the jasmine context when inlined in a test', function() { + var tested = false; + + inject(function() { + expect(this instanceof jasmine.Spec).toBe(true); + tested = true; + }); + + expect(tested).toBe(true); + }); + }); + + // We don't run the following tests on IE8. // IE8 throws "Object does not support this property or method." error, // when thrown from a function defined on window (which `inject` is).