Fix test for updateAttribute
This commit is contained in:
parent
76a2f9a22c
commit
27af51a0d9
|
@ -392,6 +392,14 @@ AbstractClass.prototype.propertyChanged = function (attr) {
|
||||||
};
|
};
|
||||||
|
|
||||||
AbstractClass.prototype.reload = function (cb) {
|
AbstractClass.prototype.reload = function (cb) {
|
||||||
|
var obj = this.constructor.cache[this.id];
|
||||||
|
if (obj) {
|
||||||
|
Object.keys(obj).forEach(function (k) {
|
||||||
|
if (obj.propertyChanged(k)) {
|
||||||
|
obj[k] = obj[k + '_was'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
this.constructor.find(this.id, cb);
|
this.constructor.find(this.id, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -218,13 +218,13 @@ function testOrm(schema) {
|
||||||
post.updateAttribute('title', 'New title', function () {
|
post.updateAttribute('title', 'New title', function () {
|
||||||
test.equal(post.title, 'New title');
|
test.equal(post.title, 'New title');
|
||||||
test.ok(!post.propertyChanged('title'));
|
test.ok(!post.propertyChanged('title'));
|
||||||
test.equal(post.content, 'New content');
|
test.equal(post.content, 'New content', 'dirty state saved');
|
||||||
test.ok(post.propertyChanged('content'));
|
test.ok(post.propertyChanged('content'));
|
||||||
post.reload(function () {
|
post.reload(function () {
|
||||||
test.equal(post.title, 'New title');
|
test.equal(post.title, 'New title');
|
||||||
test.ok(!post.propertyChanged('title'));
|
test.ok(!post.propertyChanged('title'));
|
||||||
test.equal(post.content, 'content');
|
test.equal(post.content, 'content', 'real value turned back');
|
||||||
test.ok(!post.propertyChanged('content'));
|
test.ok(!post.propertyChanged('content'), 'content unchanged');
|
||||||
test.done();
|
test.done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue