mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Fix 'You must choose a category' when a category is already chosen
This commit is contained in:
parent
30cfa33629
commit
adbb6a19bb
2 changed files with 16 additions and 0 deletions
|
@ -334,6 +334,10 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
reply: opts.reply || this.get("reply") || ""
|
||||
});
|
||||
|
||||
if (!this.get('categoryName') && !Discourse.SiteSettings.allow_uncategorized_topics && Discourse.Category.list().length > 0) {
|
||||
this.set('categoryName', Discourse.Category.list()[0].get('name'));
|
||||
}
|
||||
|
||||
if (opts.postId) {
|
||||
this.set('loading', true);
|
||||
Discourse.Post.load(opts.postId).then(function(result) {
|
||||
|
|
|
@ -176,3 +176,15 @@ test('clearState', function() {
|
|||
blank(composer.get('title'));
|
||||
|
||||
});
|
||||
|
||||
test('initial category when uncategorized is allowed', function() {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = true;
|
||||
var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
|
||||
equal(composer.get('categoryName'),undefined,"Uncategorized by default");
|
||||
});
|
||||
|
||||
test('initial category when uncategorized is not allowed', function() {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
||||
var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
|
||||
ok(composer.get('categoryName') !== undefined, "Not uncategorized by default");
|
||||
});
|
Loading…
Reference in a new issue