staff can always upload a file

This commit is contained in:
Régis Hanol
2013-09-07 10:49:11 +02:00
parent b87a78f7b2
commit eae30d7816
7 changed files with 35 additions and 9 deletions

View File

@ -24,7 +24,6 @@ test("uploading one file", function() {
test("new user cannot upload images", function() {
Discourse.SiteSettings.newuser_max_images = 0;
this.stub(Discourse.User, 'currentProp').withArgs("trust_level").returns(0);
this.stub(bootbox, "alert");
ok(!validUpload([{name: "image.png"}]));
@ -33,7 +32,6 @@ test("new user cannot upload images", function() {
test("new user cannot upload attachments", function() {
Discourse.SiteSettings.newuser_max_attachments = 0;
this.stub(Discourse.User, 'currentProp').withArgs("trust_level").returns(0);
this.stub(bootbox, "alert");
ok(!validUpload([{name: "roman.txt"}]));
@ -52,6 +50,7 @@ test("ensures an authorized upload", function() {
test("prevents files that are too big from being uploaded", function() {
var image = { name: "image.png", size: 10 * 1024 };
Discourse.SiteSettings.max_image_size_kb = 5;
Discourse.User.currentProp("trust_level", 1);
this.stub(bootbox, "alert");
ok(!validUpload([image]));
@ -70,6 +69,7 @@ var dummyBlob = function() {
};
test("allows valid uploads to go through", function() {
Discourse.User.currentProp("trust_level", 1);
Discourse.SiteSettings.max_image_size_kb = 15;
this.stub(bootbox, "alert");

View File

@ -0,0 +1,2 @@
/*jshint maxlen:10000000 */
Discourse.URL_FIXTURES["/draft.json"] = {};

File diff suppressed because one or more lines are too long

View File

@ -16,4 +16,12 @@ 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");
});