Correct seenMessage use in menu

Closes #5519
This commit is contained in:
Blade Barringer
2015-06-29 08:58:51 -05:00
parent 522181890e
commit 567ed1f28b
3 changed files with 30 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ describe('Auth Controller', function() {
beforeEach(function(){ beforeEach(function(){
module(function($provide) { module(function($provide) {
$provide.value('Analytics', analyticsMock); $provide.value('Analytics', analyticsMock);
$provide.value('Chat', { seenMessage: function() {} });
}); });
inject(function(_$httpBackend_, $rootScope, $controller) { inject(function(_$httpBackend_, $rootScope, $controller) {
@@ -22,21 +23,29 @@ describe('Auth Controller', function() {
}) })
}); });
it('should log in users with correct uname / pass', function() { describe('logging in', function() {
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
scope.auth(); it('should log in users with correct uname / pass', function() {
$httpBackend.flush(); $httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
expect(user.authenticate).to.be.calledOnce; scope.auth();
expect($window.alert).to.not.be.called; $httpBackend.flush();
expect(user.authenticate).to.be.calledOnce;
expect($window.alert).to.not.be.called;
});
it('should not log in users with incorrect uname / pass', function() {
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
scope.auth();
$httpBackend.flush();
expect(user.authenticate).to.not.be.called;
expect($window.alert).to.be.calledOnce;
});
}); });
it('should not log in users with incorrect uname / pass', function() { describe('clearMessage', function() {
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, ''); it('is Chat.seenMessage', inject(function(Chat) {
scope.auth(); expect(scope.clearMessages).to.eql(Chat.seenMessage);
$httpBackend.flush(); }));
expect(user.authenticate).to.not.be.called;
expect($window.alert).to.be.calledOnce;
}); });
}); });
}); });

View File

@@ -5,8 +5,8 @@
*/ */
angular.module('habitrpg') angular.module('habitrpg')
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','ApiUrl', '$modal', 'Analytics', .controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','ApiUrl', '$modal', 'Analytics', 'Chat',
function($scope, $rootScope, User, $http, $location, $window, ApiUrl, $modal, Analytics) { function($scope, $rootScope, User, $http, $location, $window, ApiUrl, $modal, Analytics, Chat) {
$scope.Analytics = Analytics; $scope.Analytics = Analytics;
$scope.logout = function() { $scope.logout = function() {
@@ -102,6 +102,7 @@ angular.module('habitrpg')
} }
}; };
// @TODO: Pull out menu stuff into separate menu controller
$scope.expandMenu = function(menu) { $scope.expandMenu = function(menu) {
$scope._expandedMenu = ($scope._expandedMenu == menu) ? null : menu; $scope._expandedMenu = ($scope._expandedMenu == menu) ? null : menu;
}; };
@@ -121,6 +122,8 @@ angular.module('habitrpg')
} }
}; };
$scope.clearMessages = Chat.seenMessage;
$scope.iconClasses = function() { $scope.iconClasses = function() {
return selectNotificationValue( return selectNotificationValue(
"glyphicon-gift", "glyphicon-gift",

View File

@@ -92,7 +92,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}')
li li
a(ui-sref='options.profile.stats')=env.t('stats') a(ui-sref='options.profile.stats')=env.t('stats')
li li
a(ui-sref='options.profile.profile')=env.t('profile') a(ui-sref='options.profile.profile')=env.t('profile')
li.toolbar-button-dropdown li.toolbar-button-dropdown
a(ui-sref='options.social.inbox', ng-if='user.inbox.newMessages') a(ui-sref='options.social.inbox', ng-if='user.inbox.newMessages')
span.badge.badge-danger {{user.inbox.newMessages}} span.badge.badge-danger {{user.inbox.newMessages}}
@@ -171,7 +171,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}')
ul.toolbar-subscribe(ng-if='!user.purchased.plan.customerId') ul.toolbar-subscribe(ng-if='!user.purchased.plan.customerId')
li.toolbar-subscribe-button li.toolbar-subscribe-button
button.highlight(ui-sref='options.settings.subscription',popover-trigger='mouseenter',popover-placement='bottom',popover-title=env.t('subscriptions'),popover=env.t('subDescription'),popover-append-to-body='true')=env.t('subscribe') button.highlight(ui-sref='options.settings.subscription',popover-trigger='mouseenter',popover-placement='bottom',popover-title=env.t('subscriptions'),popover=env.t('subDescription'),popover-append-to-body='true')=env.t('subscribe')
ul.toolbar-options ul.toolbar-options
li.toolbar-notifs li.toolbar-notifs
a(ng-click='expandMenu("notifs")') a(ng-click='expandMenu("notifs")')
span.glyphicon(ng-class='iconClasses()') span.glyphicon(ng-class='iconClasses()')
@@ -200,7 +200,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}')
a(ng-click='k==party._id ? $state.go("options.social.party") : $state.go("options.social.guilds.detail",{gid:k}); expandMenu(null)') a(ng-click='k==party._id ? $state.go("options.social.party") : $state.go("options.social.guilds.detail",{gid:k}); expandMenu(null)')
span.glyphicon.glyphicon-comment span.glyphicon.glyphicon-comment
span {{v.name}} span {{v.name}}
a(ng-click='Groups.seenMessage(k)', popover=env.t('clear'),popover-placement='right',popover-trigger='mouseenter',popover-append-to-body='true') a(ng-click='clearMessages(k)', popover=env.t('clear'),popover-placement='right',popover-trigger='mouseenter',popover-append-to-body='true')
span.glyphicon.glyphicon-remove-circle span.glyphicon.glyphicon-remove-circle
// li(ng-if='user.items.special.valentineReceived[0] || user.items.special.nyeReceived[0]') // li(ng-if='user.items.special.valentineReceived[0] || user.items.special.nyeReceived[0]')
a(ng-click='$state.go("options.inventory.drops"); expandMenu(null)') a(ng-click='$state.go("options.inventory.drops"); expandMenu(null)')