Prevent publisher from closing in preview mode

Fixes #7245
This commit is contained in:
Steffen van Bergerem 2017-08-09 22:11:14 +02:00
parent 32233ccb99
commit dc828e0e5a
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
2 changed files with 27 additions and 2 deletions

View file

@ -407,8 +407,8 @@ app.views.Publisher = Backbone.View.extend({
},
tryClose : function(){
// if it is not submittable, close it.
if( !this._submittable() ){
// if it is not submittable and not in preview mode, close it.
if (!this._submittable() && !this.markdownEditor.isPreviewMode()) {
this.close();
}
},

View file

@ -252,6 +252,31 @@ describe("app.views.Publisher", function() {
});
});
describe("tryClose", function() {
it("doesn't close the publisher if it is submittable", function() {
spyOn(this.view, "_submittable").and.returnValue(true);
spyOn(this.view, "close");
this.view.tryClose();
expect(this.view.close).not.toHaveBeenCalled();
});
it("doesn't close the publisher if it is in preview mode", function() {
spyOn(this.view, "_submittable").and.returnValue(false);
spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(true);
spyOn(this.view, "close");
this.view.tryClose();
expect(this.view.close).not.toHaveBeenCalled();
});
it("closes the publisher if it is neither submittable nor in preview mode", function() {
spyOn(this.view, "_submittable").and.returnValue(false);
spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(false);
spyOn(this.view, "close");
this.view.tryClose();
expect(this.view.close).toHaveBeenCalled();
});
});
describe("_beforeUnload", function(){
it("calls _submittable", function(){
spyOn(this.view, "_submittable");