diff --git a/cms/static/coffee/spec/views/section_spec.coffee b/cms/static/coffee/spec/views/section_spec.coffee index 13bb2a7e28..5137021038 100644 --- a/cms/static/coffee/spec/views/section_spec.coffee +++ b/cms/static/coffee/spec/views/section_spec.coffee @@ -74,3 +74,10 @@ describe "CMS.Views.SectionEdit", -> expect(@view.showInvalidMessage).toHaveBeenCalledWith( jasmine.any(Object), "BLARRGH", jasmine.any(Object)) expect(@view.switchToShowView).not.toHaveBeenCalled() + + it "should not save when validation is unsuccessful", -> + spyOn(@model, 'validate').andReturn("BLARRGH") + @view.$("input[type=text]").val("changed") + @view.$("input[type=submit]").click() + expect(@model.get('name')).not.toEqual("changed") + diff --git a/cms/static/js/views/section.js b/cms/static/js/views/section.js index a3fe6e03f1..c55a38ad38 100644 --- a/cms/static/js/views/section.js +++ b/cms/static/js/views/section.js @@ -68,6 +68,7 @@ CMS.Views.SectionEdit = Backbone.View.extend({ this.showView.render(); }, showInvalidMessage: function(model, error, options) { + model.set("name", model.previous("name")); var that = this; var msg = new CMS.Models.ErrorMessage({ title: gettext("Your change could not be saved"),