 			i++
 		expect(i).toBe 2
 
+	describe "default values", ->
+		class Test extends Model
+			fields:
+				foo:
+					"default": "FOO"
+				bar:
+					"default": "BAR"
+
+		it "should be applied when creating the model", ->
+			model = new Test
+			expect(model.get "foo").toBe "FOO"
+			expect(model.get "bar").toBe "BAR"
+
+		it "should be overridden by initially supplied values", ->
+			model = new Test
+				bar: "other"
+			expect(model.get "foo").toBe "FOO"
+			expect(model.get "bar").toBe "other"
+
 	describe "change events", ->
 		change = null
 		changeEvent = null

					relation: "HasMany"

		beforeEach ->
			model = new RelationalModel

		it "should return relation definitions", ->
			foo = model._getRelation "foo"
			bar = model._getRelation "bar"
			expect(typeof foo).toBe "object"
			expect(typeof bar).toBe "object"
			expect(foo instanceof HasOne).toBe true
			expect(bar instanceof HasMany).toBe true

	xdescribe "relations", ->
		class RelationalModel extends Model
			persistor: TestPersistor
			relations:
				foo:
					model: Model
				bar:
					collection: Collection
					model: Model
		model = null
		foo = null
		bar = [null,null,null]
		beforeEach ->
			foo = new Model
			foo.id "foo"
			bar[0] = new Model
			bar[1] = new Model
			bar[2] = new Model
			bar[0].id "bar:0"
			bar[1].id "bar:1"
			bar[2].id "bar:2"
			TestPersistor.add foo, bar
			model = new RelationalModel
			model.set
				foo: foo
				bar: new Collection bar

		afterEach ->
			TestPersistor.reset()

		it "should not fetch anything if all relations are loaded", ->
			load = sinon.spy model.getPersistor(), "load"
			done = sinon.spy()
			model.fetch done
			waitsFor (-> done.called), "Done never called", 100
			runs ->
				expect(load.callCount).toBe 0
				call = done.getCall 0
				expect(call.args[0]).toBe null

		it "should serialize relations to ID", ->
			serial = model.serialize()
			expect(serial.foo).toBe "foo"
			expect(JSON.stringify(serial.bar)).toBe JSON.stringify(["bar:0","bar:1","bar:2"])

		it "should contain the raw IDs when deserializing", ->
			model = new RelationalModel model.serialize()
			expect(model.get "foo").toBe "foo"
			expect(JSON.stringify(model.get "bar")).toBe JSON.stringify(["bar:0","bar:1","bar:2"])

		it "should fetch all relations", ->
			model = new RelationalModel model.serialize()
			#load = sinon.spy model.getPersistor(), "load"
			done = sinon.spy()
			model.fetch done
			waitsFor (-> done.called), "Done never called", 100
			runs ->
				#expect(load.callCount).toBe 4
				expect(model.get "foo").toBe foo
				collection = model.get "bar"
				expect(collection.size()).toBe 3
				expect(collection.get 0).toBe bar[0]
				expect(collection.get 1).toBe bar[1]
				expect(collection.get 2).toBe bar[2]

#		it "should complain if model relations do not have an ID when saving", ->
#			done = sinon.spy()
#			model.set "foo", new Model
#			model.save done
#			waitsFor (-> done.called), "Done never called", 100
#			runs ->
#				err = done.getCall(0).args[0]
#				expect(err.message).toBe "Relation \"foo\" does not have an ID when saving model"

		it "should complain if collection relation entries do not have an ID when saving", ->
			done = sinon.spy()
			model.get("bar").add new Model
			model.save done
#			waitsFor (-> done.called), "Done never called", 100
			#runs ->
			#	err = done.getCall(0).args[0]
			#	expect(err.message).toBe "Entry in collection relation \"bar\" does not have an ID when saving model"

		expect(model.get "id").toBe undefined
		expect(model.get "foo").toBe "foo"
		expect(model.get "bar").toBe "bar"

	it "should copy values when setting a whole model", ->
		other = new Model
