2016-12-06 23:06:56 -05:00
|
|
|
import { currentUser } from "helpers/qunit-helpers";
|
|
|
|
|
2016-12-15 03:52:47 -05:00
|
|
|
moduleFor('component:group-membership-button');
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2016-12-15 03:52:47 -05:00
|
|
|
test('canJoinGroup', function() {
|
2016-12-06 23:06:56 -05:00
|
|
|
this.subject().setProperties({
|
|
|
|
model: { public: false }
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(this.subject().get("canJoinGroup"), false, "non public group cannot be joined");
|
|
|
|
|
|
|
|
this.subject().set("model.public", true);
|
|
|
|
|
|
|
|
equal(this.subject().get("canJoinGroup"), true, "public group can be joined");
|
|
|
|
|
|
|
|
this.subject().setProperties({ currentUser: null, model: { public: true } });
|
|
|
|
|
2016-12-29 00:46:56 -05:00
|
|
|
equal(this.subject().get("canJoinGroup"), true, "can't join group when not logged in");
|
2016-12-06 23:06:56 -05:00
|
|
|
});
|
2016-12-12 09:46:45 -05:00
|
|
|
|
|
|
|
test('canRequestMembership', function() {
|
|
|
|
this.subject().setProperties({
|
|
|
|
model: { allow_membership_requests: false, alias_level: 0 }
|
2016-12-12 09:52:57 -05:00
|
|
|
});
|
2016-12-12 09:46:45 -05:00
|
|
|
|
|
|
|
equal(this.subject().get('canRequestMembership'), false);
|
|
|
|
|
|
|
|
this.subject().setProperties({
|
|
|
|
currentUser: currentUser(), model: { allow_membership_requests: true, alias_level: 99 }
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(this.subject().get('canRequestMembership'), true);
|
|
|
|
|
|
|
|
this.subject().set("model.alias_level", 0);
|
|
|
|
|
|
|
|
equal(this.subject().get('canRequestMembership'), false);
|
|
|
|
});
|
2017-01-03 01:36:56 -05:00
|
|
|
|
|
|
|
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);
|
2017-03-15 23:33:55 -04:00
|
|
|
|
|
|
|
this.subject().setProperties({
|
|
|
|
groupUserIds: [1, 3],
|
|
|
|
model: { id: 1, is_group_user: false }
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(this.subject().get('userIsGroupUser'), false);
|
2017-01-03 01:36:56 -05:00
|
|
|
});
|