Backbone section: don't save name on validation error

This commit is contained in:
David Baumgold
2013-05-17 13:24:36 -04:00
parent 55cd8afe34
commit 0052eaacbc
2 changed files with 8 additions and 0 deletions

View File

@@ -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")