Fix memory adapter: broken upd attrs

This commit is contained in:
Anatoliy Chakkaev 2013-03-30 21:07:16 +04:00
parent 2f048e79c0
commit 5b429e8d41
2 changed files with 24 additions and 1 deletions

View File

@ -181,7 +181,7 @@ Memory.prototype.count = function count(model, callback, where) {
Memory.prototype.updateAttributes = function updateAttributes(model, id, data, cb) { Memory.prototype.updateAttributes = function updateAttributes(model, id, data, cb) {
data.id = id; data.id = id;
var base = this.cache[model][id]; var base = JSON.parse(this.cache[model][id]);
this.save(model, merge(base, data), cb); this.save(model, merge(base, data), cb);
}; };

View File

@ -148,6 +148,29 @@ describe('manipulation', function() {
}).should.throw('Validation error'); }).should.throw('Validation error');
}); });
}); });
});
describe('updateAttributes', function() {
var person;
before(function(done) {
Person.destroyAll(function() {
person = Person.create(done);
});
});
it('should update one attribute', function(done) {
person.updateAttribute('name', 'Paul Graham', function(err, p) {
should.not.exist(err);
Person.all(function(e, ps) {
should.not.exist(err);
ps.should.have.lengthOf(1);
ps.pop().name.should.equal('Paul Graham');
done();
});
});
});
}); });
describe('destroy', function() { describe('destroy', function() {