Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/scripts/directives/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location

scope.logout = function() {
AccessToken.destroy(scope);
$rootScope.$broadcast('oauth:logout');
loggedOut();
};

Expand All @@ -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';
};

Expand Down
3 changes: 2 additions & 1 deletion dist/oauth-ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location

scope.logout = function() {
AccessToken.destroy(scope);
$rootScope.$broadcast('oauth:logout');
loggedOut();
};

Expand All @@ -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';
};

Expand Down
15 changes: 12 additions & 3 deletions test/spec/directives/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -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);
});
});
});
Expand All @@ -165,7 +170,7 @@ describe('oauth', function() {
});

beforeEach(function() {
$rootScope.$on('oauth:logout', callback);
$rootScope.$on('oauth:loggedOut', callback);
});

beforeEach(function() {
Expand Down Expand Up @@ -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);
});
});


Expand Down