A platform for community discussion. Free, open, simple.
FIX: Always save post drafts no matter content length (#35540)
Martin Brennanb95239c8a9a1
diff --git a/frontend/discourse/app/models/composer.js b/frontend/discourse/app/models/composer.jsindex cdad1de9d86..cc3759ab5fa 100644--- a/frontend/discourse/app/models/composer.js+++ b/frontend/discourse/app/models/composer.js@@ -1336,23 +1336,16 @@ export default class Composer extends RestModel {return false;}- // Do not save when drafts are disabledif (this.disableDrafts) {return false;}+ // Title is only edited when editing topic OP or making a new topic.if (this.canEditTitle) {- // Save title and/or post bodyif (isEmpty(this.title) && isEmpty(this.reply)) {return false;}-- // Do not save when both title and reply's length are too small- if (!this.titleLengthValid && this.replyLength < this.minimumPostLength) {- return false;- }} else {- // Do not save when there is no replyif (isEmpty(this.reply)) {return false;}diff --git a/spec/system/composer/drafts_spec.rb b/spec/system/composer/drafts_spec.rbindex fce9bea895b..55e42bf00ed 100644--- a/spec/system/composer/drafts_spec.rb+++ b/spec/system/composer/drafts_spec.rb@@ -41,17 +41,31 @@ describe "Composer - Drafts", type: :system doendend- context "when only title is specified and it is too short" do- it "does not save the draft or show a toast" do+ context "when only title is specified and it is less than min_topic_title_length" do+ it "does saves the draft and shows a toast" dovisit "/new-topic"expect(composer).to be_opened- composer.fill_title("test")+ composer.fill_title("x")composer.closeexpect(composer).to be_closed- expect(toasts).to have_no_message- expect(Draft.where(user: current_user).count).to eq(0)+ expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))+ expect(Draft.where(user: current_user).count).to eq(1)+ end+ end++ context "when only body is specified and it is less than min_post_length" do+ it "does saves the draft and shows a toast" do+ visit "/new-topic"++ expect(composer).to be_opened+ composer.fill_content("x")+ composer.close+ expect(composer).to be_closed++ expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))+ expect(Draft.where(user: current_user).count).to eq(1)endendend