composer now prevents you from submitting an empty frame.
This commit is contained in:
parent
d270910500
commit
bed07872f2
2 changed files with 28 additions and 1 deletions
|
|
@ -123,11 +123,18 @@ app.views.framerControls = app.views.Base.extend({
|
|||
},
|
||||
|
||||
saveFrame : function(){
|
||||
this.$('input').prop('disabled', 'disabled')
|
||||
this.setFormAttrs()
|
||||
if(this.inValidFrame()) {
|
||||
return false;
|
||||
}
|
||||
this.$('input').prop('disabled', 'disabled')
|
||||
this.model.save()
|
||||
},
|
||||
|
||||
inValidFrame : function(){
|
||||
return (this.model.get('text').trim().length == 0) && (this.model.get('photos').length == 0)
|
||||
},
|
||||
|
||||
editFrame : function(){
|
||||
app.router.renderPage(function(){return new app.pages.Composer({model : app.frame})})
|
||||
app.router.navigate("/posts/new")
|
||||
|
|
|
|||
|
|
@ -14,5 +14,25 @@ describe("rendering", function(){
|
|||
this.view.$("input.done").click();
|
||||
expect(this.view.$('input').prop('disabled')).toBeTruthy();
|
||||
});
|
||||
|
||||
it("does not disable the frame if it is invaild", function(){
|
||||
spyOn(this.view, 'inValidFrame').andReturn(true)
|
||||
this.view.$("input.done").click();
|
||||
expect(this.view.$('input').prop('disabled')).toBeFalsy();
|
||||
});
|
||||
|
||||
it("does not disable the frame if it is invaild", function(){
|
||||
spyOn(this.view.model, 'save')
|
||||
spyOn(this.view, 'inValidFrame').andReturn(true)
|
||||
this.view.$("input.done").click();
|
||||
expect(this.view.model.save).not.toHaveBeenCalled()
|
||||
});
|
||||
})
|
||||
|
||||
describe("inValidFrame", function(){
|
||||
it("is invalid if the frame has no text or photos", function(){
|
||||
this.view.model = new factory.statusMessage({text: '', photos : []})
|
||||
expect(this.view.inValidFrame).toBeTruthy();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue