mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: admins bypass some post validations. This allows them to edit legal docs even if those docs are longer than max post length, for example.
This commit is contained in:
@ -1,4 +1,12 @@
|
||||
module("Discourse.Composer");
|
||||
module("Discourse.Composer", {
|
||||
setup: function() {
|
||||
sinon.stub(Discourse.User, 'currentProp').withArgs('admin').returns(false);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Discourse.User.currentProp.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('replyLength', function() {
|
||||
var replyLength = function(val, expectedLength) {
|
||||
@ -231,3 +239,32 @@ test('open with a quote', function() {
|
||||
equal(new_composer().get('originalText'), quote, "originalText is the quote" );
|
||||
equal(new_composer().get('replyDirty'), false, "replyDirty is initally false with a quote" );
|
||||
});
|
||||
|
||||
|
||||
module("Discourse.Composer as admin", {
|
||||
setup: function() {
|
||||
sinon.stub(Discourse.User, 'currentProp').withArgs('admin').returns(true);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Discourse.User.currentProp.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("Title length for regular topics as admin", function() {
|
||||
Discourse.SiteSettings.min_topic_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
var composer = Discourse.Composer.create();
|
||||
|
||||
composer.set('title', 'asdf');
|
||||
ok(composer.get('titleLengthValid'), "admins can use short titles");
|
||||
|
||||
composer.set('title', 'this is a long title');
|
||||
ok(composer.get('titleLengthValid'), "admins can use long titles");
|
||||
|
||||
composer.set('title', 'just right');
|
||||
ok(composer.get('titleLengthValid'), "in the range is okay");
|
||||
|
||||
composer.set('title', '');
|
||||
ok(!composer.get('titleLengthValid'), "admins must set title to at least 1 character");
|
||||
});
|
Reference in New Issue
Block a user