diff --git a/README.md b/README.md index 2f71f41..084bfb6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# deployd v0.6.9 +# deployd v0.6.10 [![Build Status](https://secure.travis-ci.org/deployd/deployd.png)](http://travis-ci.org/deployd/deployd) diff --git a/lib/resources/collection/index.js b/lib/resources/collection/index.js index 7c20a73..3887009 100644 --- a/lib/resources/collection/index.js +++ b/lib/resources/collection/index.js @@ -440,7 +440,13 @@ Collection.prototype.save = function (ctx, fn) { }; domain.changed = function (property) { - if(domain.data.hasOwnProperty(property)) return true; + if(domain.data.hasOwnProperty(property)) { + if(domain.previous && domain.previous[property] === domain.data[property]) { + return false; + } + + return true; + } return false; }; @@ -466,7 +472,8 @@ Collection.prototype.save = function (ctx, fn) { prev[key] = obj[key]; obj[key] = item[key]; }); - + + prev.id = id; item = obj; domain['this'] = item; domain.data = item; diff --git a/package.json b/package.json index 28f9027..811f0ae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Ritchie Martori", "name": "deployd", - "version": "0.6.9", + "version": "0.6.10", "description": "the simplest way to build realtime APIs for web and mobile apps", "repository": { "url": "git://github.com/deployd/deployd.git" diff --git a/test-app/public/test/collection.test.js b/test-app/public/test/collection.test.js index 6783ff8..911ec74 100644 --- a/test-app/public/test/collection.test.js +++ b/test-app/public/test/collection.test.js @@ -871,6 +871,17 @@ describe('Collection', function() { }); }); + it('should not return true when a value has not changed', function(done) { + dpd.changed.post({name: '$NO_CHANGE'}, function (c) { + dpd.changed.put(c.id, {name: '$NO_CHANGE'}, function (c) { + if(c.name != '$NO_CHANGE') { + throw new Error('incorrect name change'); + } + done(); + }); + }); + }); + afterEach(function (done) { this.timeout(10000); cleanCollection(dpd.changed, done); diff --git a/test-app/resources/changed/put.js b/test-app/resources/changed/put.js new file mode 100644 index 0000000..dfedcb6 --- /dev/null +++ b/test-app/resources/changed/put.js @@ -0,0 +1,5 @@ +if(this.name === '$NO_CHANGE') { + if(changed('name')) { + this.name = 'saw name change'; + } +} \ No newline at end of file