Test embedsOne CRUD methods

This commit is contained in:
Fabien Franzen 2015-03-21 16:23:25 +01:00
parent 911d8323b4
commit 93aefc36f5
1 changed files with 49 additions and 2 deletions

View File

@ -636,8 +636,7 @@ describe('relations - integration', function() {
function(err, group) {
if (err) return done(err);
test.group = group;
group.cover.build({ url: 'http://image.url' });
group.save(done);
done();
});
});
@ -645,6 +644,19 @@ describe('relations - integration', function() {
this.app.models.group.destroyAll(done);
});
it('creates an embedded model', function(done) {
var url = '/api/groups/' + this.group.id + '/cover';
this.post(url)
.send({ url: 'http://image.url' })
.expect(200, function(err, res) {
expect(res.body).to.be.eql(
{ url: 'http://image.url' }
);
done();
});
});
it('includes the embedded models', function(done) {
var url = '/api/groups/' + this.group.id;
@ -670,6 +682,41 @@ describe('relations - integration', function() {
});
});
it('updates an embedded model', function(done) {
var url = '/api/groups/' + this.group.id + '/cover';
this.put(url)
.send({ url: 'http://changed.url' })
.expect(200, function(err, res) {
expect(res.body.url).to.be.equal('http://changed.url');
done();
});
});
it('returns the updated embedded model', function(done) {
var url = '/api/groups/' + this.group.id + '/cover';
this.get(url)
.expect(200, function(err, res) {
expect(res.body).to.be.eql(
{ url: 'http://changed.url' }
);
done();
});
});
it('deletes an embedded model', function(done) {
var url = '/api/groups/' + this.group.id + '/cover';
this.del(url).expect(204, done);
});
it('deleted the embedded model', function(done) {
var url = '/api/groups/' + this.group.id + '/cover';
this.get(url).expect(404, done);
});
});
describe('embedsMany', function() {