Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created November 5, 2011 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnagir/1342183 to your computer and use it in GitHub Desktop.
Save dnagir/1342183 to your computer and use it in GitHub Desktop.
Model spec for boolean
it("can understand checkboxes as booleans", function(){
var form = $('<form />');
form.append('<input name="available" value="1" checked="checked" />');
var asset = Asset.fromForm(form);
expect(asset.available).toEqual(true);
form.find('input').prop('checked', false);
expect(Asset.fromForm(form).available).toEqual(false);
});
// Or otherwise you'd have to do inn each (coffee) model something like:
// fromForm: (f) ->
// super
// @available = @available == '1' # and for each boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment