mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
staff can always upload a file
This commit is contained in:
@ -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");
|
||||
|
||||
|
2
test/javascripts/fixtures/draft_fixtures.js
Normal file
2
test/javascripts/fixtures/draft_fixtures.js
Normal file
@ -0,0 +1,2 @@
|
||||
/*jshint maxlen:10000000 */
|
||||
Discourse.URL_FIXTURES["/draft.json"] = {};
|
File diff suppressed because one or more lines are too long
@ -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");
|
||||
});
|
||||
|
Reference in New Issue
Block a user