diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index 08cf7c0..f47478d 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,6 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -85,7 +86,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; diff --git a/dist/oauth-ng.js b/dist/oauth-ng.js index 0d1972a..6883503 100644 --- a/dist/oauth-ng.js +++ b/dist/oauth-ng.js @@ -369,6 +369,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -380,7 +381,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index e5e34c8..1d4b2de 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -141,6 +141,10 @@ describe('oauth', function() { $rootScope.$on('oauth:logout', callback); }); + beforeEach(function() { + $rootScope.$on('oauth:loggedOut', callback); + }); + beforeEach(function() { element.find('.logged-in').click(); }); @@ -150,9 +154,10 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:logout and oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); + expect(callback.calls.count()).toBe(2); }); }); }); @@ -165,7 +170,7 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -195,10 +200,14 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); + + it('does not fire the oauth:logout event', function() { + expect(callback.calls.count()).toBe(1); + }); });