FEATURE: Add group settngs to allow users to leave a group freely.

https://meta.discourse.org/t/split-join-leave-freely-setting-on-groups/65565
This commit is contained in:
Guo Xiang Tan
2017-07-28 11:37:10 +09:00
parent 5012d46cbd
commit 4620dfe92d
25 changed files with 315 additions and 89 deletions

View File

@ -2,18 +2,52 @@ moduleFor('component:group-membership-button');
QUnit.test('canJoinGroup', function(assert) {
this.subject().setProperties({
model: { public: false }
model: { public_admission: false, is_group_user: true }
});
assert.equal(this.subject().get("canJoinGroup"), false, "non public group cannot be joined");
assert.equal(
this.subject().get("canJoinGroup"), false,
"can't join group if public_admission is false"
);
this.subject().set("model.public", true);
this.subject().set("model.public_admission", true);
assert.equal(this.subject().get("canJoinGroup"), true, "public group can be joined");
assert.equal(
this.subject().get("canJoinGroup"), false,
"can't join group if user is already in the group"
);
this.subject().setProperties({ currentUser: null, model: { public: true } });
this.subject().set("model.is_group_user", false);
assert.equal(this.subject().get("canJoinGroup"), true, "can't join group when not logged in");
assert.equal(
this.subject().get("canJoinGroup"), true,
"allowed to join group"
);
});
QUnit.test('canLeaveGroup', function(assert) {
this.subject().setProperties({
model: { public_exit: false, is_group_user: false }
});
assert.equal(
this.subject().get("canLeaveGroup"), false,
"can't leave group if public_exit is false"
);
this.subject().set("model.public_exit", true);
assert.equal(
this.subject().get("canLeaveGroup"), false,
"can't leave group if user is not in the group"
);
this.subject().set("model.is_group_user", true);
assert.equal(
this.subject().get("canLeaveGroup"), true,
"allowed to leave group"
);
});
QUnit.test('userIsGroupUser', function(assert) {