mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: use correct site setting when uploading images
This commit is contained in:
parent
c05aced094
commit
6391db5921
|
@ -664,10 +664,12 @@ const User = RestModel.extend({
|
|||
},
|
||||
|
||||
isAllowedToUploadAFile(type) {
|
||||
const settingName = type === "image" ? "embedded_media" : "attachments";
|
||||
|
||||
return (
|
||||
this.staff ||
|
||||
this.trust_level > 0 ||
|
||||
this.siteSettings[`newuser_max_${type}s`] > 0
|
||||
this.siteSettings[`newuser_max_${settingName}`] > 0
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -56,6 +56,31 @@ QUnit.test("new user cannot upload images", function(assert) {
|
|||
);
|
||||
});
|
||||
|
||||
QUnit.test("new user can upload images if allowed", function(assert) {
|
||||
this.siteSettings.newuser_max_embedded_media = 1;
|
||||
this.siteSettings.default_trust_level = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.ok(
|
||||
validateUploadedFiles([{ name: "image.png" }], {
|
||||
user: User.create(),
|
||||
siteSettings: this.siteSettings
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("TL1 can upload images", function(assert) {
|
||||
this.siteSettings.newuser_max_embedded_media = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.ok(
|
||||
validateUploadedFiles([{ name: "image.png" }], {
|
||||
user: User.create({ trust_level: 1 }),
|
||||
siteSettings: this.siteSettings
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("new user cannot upload attachments", function(assert) {
|
||||
this.siteSettings.newuser_max_attachments = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
|
Loading…
Reference in New Issue
Block a user