mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
refactor isMemberOfGroup and tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe.only('Groups Controller', function() {
|
describe('Groups Controller', function() {
|
||||||
var scope, ctrl, groups, user, guild, $rootScope;
|
var scope, ctrl, groups, user, guild, $rootScope;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -34,7 +34,7 @@ describe.only('Groups Controller', function() {
|
|||||||
return [guild];
|
return [guild];
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, guild)).to.be.eql(true);
|
expect(scope.isMemberOfGroup(user._id, guild)).to.be.ok;
|
||||||
expect(myGuilds).to.be.called
|
expect(myGuilds).to.be.called
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ describe.only('Groups Controller', function() {
|
|||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, guild)).to.be.eql(false);
|
expect(scope.isMemberOfGroup(user._id, guild)).to.not.be.ok;
|
||||||
expect(myGuilds).to.be.called
|
expect(myGuilds).to.be.called
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||||||
// If the group is a guild, just check for an intersection with the
|
// If the group is a guild, just check for an intersection with the
|
||||||
// current user's guilds, rather than checking the members of the group.
|
// current user's guilds, rather than checking the members of the group.
|
||||||
if(group.type === 'guild') {
|
if(group.type === 'guild') {
|
||||||
return _.detect(Groups.myGuilds(), function(g) { return g._id === group._id }) ? true : false;
|
return _.detect(Groups.myGuilds(), function(g) { return g._id === group._id });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!group.members) return false;
|
if (!group.members) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user