Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed #107, changed() returning incorrect true when values were equal

  • Loading branch information...
commit b545a8bf1ff30abb71d2e065159bd6476ec037fe 1 parent fc4ae32
@ritch ritch authored
View
2  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)
View
11 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;
View
2  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"
View
11 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);
View
5 test-app/resources/changed/put.js
@@ -0,0 +1,5 @@
+if(this.name === '$NO_CHANGE') {
+ if(changed('name')) {
+ this.name = 'saw name change';
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.