mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 01:15:00 +08:00
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
module("Discourse.User");
|
|
|
|
test('staff', function(){
|
|
var user = Discourse.User.create({id: 1, username: 'eviltrout'});
|
|
|
|
ok(!user.get('staff'), "user is not staff");
|
|
|
|
user.toggleProperty('moderator');
|
|
ok(user.get('staff'), "moderators are staff");
|
|
|
|
user.setProperties({moderator: false, admin: true});
|
|
ok(user.get('staff'), "admins are staff");
|
|
});
|
|
|
|
test('searchContext', function() {
|
|
var user = Discourse.User.create({id: 1, username: 'EvilTrout'});
|
|
|
|
deepEqual(user.get('searchContext'), {type: 'user', id: 'eviltrout', user: user}, "has a search context");
|
|
});
|
|
|
|
test("isAllowedToUploadAFile", function() {
|
|
var user = Discourse.User.create({ trust_level: 0, admin: true });
|
|
ok(user.isAllowedToUploadAFile("image"), "admin can always upload a file");
|
|
|
|
user.setProperties({ admin: false, moderator: true });
|
|
ok(user.isAllowedToUploadAFile("image"), "moderator can always upload a file");
|
|
});
|
|
|
|
|
|
asyncTestDiscourse("findByUsername", function() {
|
|
expect(3);
|
|
|
|
Discourse.User.findByUsername('eviltrout').then(function (user) {
|
|
present(user);
|
|
equal(user.get('username'), 'eviltrout', 'it has the correct username');
|
|
equal(user.get('name'), 'Robin Ward', 'it has the full name since it has details');
|
|
start();
|
|
});
|
|
}); |