From d6da505f4e044f8a487ac27a3ec707c11853ee0a Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 30 Nov 2012 01:16:08 +0100 Subject: fix(Scope): ensure that a scope is destroyed only once Due to bd524fc4 calling $destroy() on a scope mupltiple times cases NPE. Closes #1627 --- test/ng/rootScopeSpec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ng/rootScopeSpec.js') diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index ee7fb796..55fc41b1 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -407,6 +407,22 @@ describe('Scope', function() { first.$destroy(); expect(log).toEqual('first; first-child'); })); + + + it('should $destroy a scope only once and ignore any further destroy calls', + inject(function($rootScope) { + $rootScope.$digest(); + expect(log).toBe('123'); + + first.$destroy(); + first.$apply(); + expect(log).toBe('12323'); + + first.$destroy(); + first.$destroy(); + first.$apply(); + expect(log).toBe('1232323'); + })); }); -- cgit v1.2.3