FIX: Group membership button now showing properly.

This commit is contained in:
Guo Xiang Tan 2017-01-03 14:36:56 +08:00
parent 761d524024
commit 3aed15c99e
2 changed files with 25 additions and 1 deletions

View File

@ -17,7 +17,7 @@ export default Ember.Component.extend({
if (isGroupUser) {
return isGroupUser;
} else {
return groupUserIds.includes(groupId);
return !!groupUserIds && groupUserIds.includes(groupId);
}
},

View File

@ -35,3 +35,27 @@ test('canRequestMembership', function() {
equal(this.subject().get('canRequestMembership'), false);
});
test('userIsGroupUser', function() {
this.subject().setProperties({
model: { is_group_user: true }
});
equal(this.subject().get('userIsGroupUser'), true);
this.subject().set('model.is_group_user', false);
equal(this.subject().get('userIsGroupUser'), false);
this.subject().setProperties({ model: { id: 1 }, groupUserIds: [1] });
equal(this.subject().get('userIsGroupUser'), true);
this.subject().set('groupUserIds', [3]);
equal(this.subject().get('userIsGroupUser'), false);
this.subject().set('groupUserIds', undefined);
equal(this.subject().get('userIsGroupUser'), false);
});