Permalink
Browse files

set constructor in Response

  • Loading branch information...
1 parent 6b872c9 commit 7b655309e875b1ca77c7c15b03809b3ccd022d3a cloudhead committed Aug 12, 2010
Showing with 12 additions and 0 deletions.
  1. +5 −0 lib/cradle/response.js
  2. +7 −0 test/response-test.js
View
@@ -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
@@ -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);
}
}
}

0 comments on commit 7b65530

Please sign in to comment.