Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into Merge-Move-adapter-…
Browse files Browse the repository at this point in the history
…code-to-fortune

Conflicts:
	package.json
	test/all.js
	test/app.js
	test/fixtures.json
  • Loading branch information
EugeneKostrikov committed Jun 5, 2014
1 parent 8eb32ae commit a42fe4a
Show file tree
Hide file tree
Showing 9 changed files with 742 additions and 1,466 deletions.
1,462 changes: 0 additions & 1,462 deletions test/all.js

This file was deleted.

9 changes: 7 additions & 2 deletions test/fortune-mongodb/mongodb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ module.exports = function(options){
it('should return all existing fields when no select is specified', function(done){
adapter.findMany('person')
.then(function(docs){
(Object.keys(docs[0]).length).should.equal(4);
//hooks add their black magic here.
//See what you have in fixtures + what beforeWrite hooks assign in addiction
var keys = Object.keys(docs[0]).length;
(keys).should.equal(6);
done();
});
});
Expand Down Expand Up @@ -167,7 +170,9 @@ module.exports = function(options){
it('should return all existing fields when no select is specified', function(done){
adapter.find('person', ids.people[0])
.then(function(doc){
(Object.keys(doc).length).should.equal(4);
//hooks add their black magic here.
//See what you have in fixtures + what beforeWrite hooks assign in addiction
(Object.keys(doc).length).should.equal(6);
done();
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/fortune/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('Fortune', function () {
require('./associations')(options);
require('./fields_and_filters')(options);
require('./compound_document')(options);
require('./documents_with_links')(options);
require('./includes')(options);

describe("Business key", function(){
it("can be used as primary key for individual resource requests", function(done){
Expand Down
28 changes: 28 additions & 0 deletions test/fortune/associations.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ module.exports = function(options){
});
});
});
it('should update association on PATCH', function(done){
new Promise(function(resolve){
var patch = [{
op: 'replace',
path: '/people/0/soulmate',
value: ids.people[2]
}];
request(baseUrl).patch('/people/' + ids.people[0])
.set('Content-Type', 'application/json')
.send(JSON.stringify(patch))
.expect(200)
.end(function(err, res){
should.not.exist(err);
var body = JSON.parse(res.text);
(body.people[0].links.soulmate).should.equal(ids.people[2]);
resolve();
});
}).then(function(){
request(baseUrl).get('/people/' + ids.people[2])
.expect(200)
.end(function(err, res){
should.not.exist(err);
var body = JSON.parse(res.text);
(body.people[0].links.soulmate).should.equal(ids.people[0]);
done();
});
});
});
});

describe('many to many association', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/fortune/compound_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module.exports = function(options){
});
});


//TODO: empty suite
it("should append links for external references", function(done){
request(baseUrl)
.get("/people/" + ids.people[0] + "?include=cars,cars.MOT")
Expand Down
Loading

0 comments on commit a42fe4a

Please sign in to comment.