Skip to content

Commit 52cd4ba

Browse files
committed
Allow "anonymous" models to be created.
1 parent f42bb6e commit 52cd4ba

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/model_model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
emit: function() {
5050
var anyInstance = this.constructor.anyInstance
51-
anyInstance.emit.apply(anyInstance, arguments)
51+
if (anyInstance) anyInstance.emit.apply(anyInstance, arguments)
5252
Model.EventEmitter.prototype.emit.apply(this, arguments)
5353
},
5454

test/tests/model_test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module("Model");
22

3-
test("defining attributes when instanciating a model", function() {
4-
var Post = Model("post")
5-
var post
3+
test("defining attributes when instantiating a model", function() {
4+
var attributes = { a: "a", b: "b" }
5+
var model = new Model.Model(attributes)
66

7-
post = new Post(undefined)
8-
deepEqual({}, post.attributes)
7+
deepEqual(attributes, model.attributes, "attributes are set")
98

10-
var attributes = { a: "a", b: "b" }
11-
post = new Post(attributes)
129
attributes.a = "b"
13-
deepEqual("a", post.attributes.a)
10+
11+
equal(model.attributes.a, "a", "attributes are copied")
12+
13+
deepEqual({}, new Model.Model(undefined).attributes, "attributes is an empty object")
1414
})
1515

1616
test("get, set, attributes, changes, reset, save, destroy", function() {

0 commit comments

Comments
 (0)