不要怂,就是干,撸起袖子干!

You need to sign in or sign up before continuing.
Commit ef31e540 by Daniel Durante

Made sure updatedAt was being updated when we setAttributes.

1 parent e68552f5
Showing with 19 additions and 10 deletions
......@@ -223,7 +223,7 @@ module.exports = (function() {
if (this.isNewRecord !== true) {
readOnlyAttributes.push(this.daoFactory.options.underscored === true ? 'created_at' : 'createdAt')
}
readOnlyAttributes.push(this.daoFactory.options.underscored === true ? 'updated_at' : 'updatedAt')
// readOnlyAttributes.push(this.daoFactory.options.underscored === true ? 'updated_at' : 'updatedAt')
readOnlyAttributes.push(this.daoFactory.options.underscored === true ? 'deleted_at' : 'deletedAt')
Utils._.each(updates, function(value, attr) {
......@@ -235,6 +235,11 @@ module.exports = (function() {
updateAllowed && (self[attr] = value)
})
// since we're updating the record, we should be updating the updatedAt column..
if (this.daoFactory.options.timestamps === true) {
self[this.daoFactory.options.underscored === true ? 'updated_at' : 'updatedAt'] = new Date()
}
}
DAO.prototype.destroy = function() {
......
......@@ -985,17 +985,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
identifier: 'identifier'
}).success(function(user) {
var oldCreatedAt = user.createdAt
, oldUpdatedAt = user.updatedAt
, oldIdentifier = user.identifier
user.updateAttributes({
name: 'foobar',
createdAt: new Date(2000, 1, 1),
identifier: 'another identifier'
}).success(function(user) {
expect(new Date(user.createdAt)).to.equalDate(new Date(oldCreatedAt))
expect(user.identifier).to.equal(oldIdentifier)
done()
})
setTimeout(function () {
user.updateAttributes({
name: 'foobar',
createdAt: new Date(2000, 1, 1),
identifier: 'another identifier'
}).success(function(user) {
expect(new Date(user.createdAt)).to.equalDate(new Date(oldCreatedAt))
expect(new Date(user.updatedAt)).to.not.equalTime(new Date(oldUpdatedAt))
expect(user.identifier).to.equal(oldIdentifier)
done()
})
}, 1000)
})
})
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!