Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

set constructor in Response

  • Loading branch information...
commit 7b655309e875b1ca77c7c15b03809b3ccd022d3a 1 parent 6b872c9
cloudhead authored
Showing with 12 additions and 0 deletions.
  1. +5 −0 lib/cradle/response.js
  2. +7 −0 test/response-test.js
View
5 lib/cradle/response.js
@@ -65,6 +65,11 @@ this.Response = function Response(json, response) {
}
exports.extend(obj, exports.basePrototype);
+ // Set the constructor to be this function
+ Object.defineProperty(obj, 'constructor', {
+ value: arguments.callee
+ });
+
return obj;
};
View
7 test/response-test.js
@@ -50,6 +50,13 @@ vows.describe('cradle/Response').addBatch({
'should respond to both `id` and `_id`': function (topic) {
assert.equal (topic.id, 'f6av8');
assert.equal (topic._id, 'f6av8');
+ },
+ 'should respond to both `rev` and `_rev`': function (topic) {
+ assert.equal (topic.rev, '2-76be');
+ assert.equal (topic._rev, '2-76be');
+ },
+ 'should have Response as its constructor': function (topic) {
+ assert.equal (topic.constructor, cradle.Response);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.