Test embedsOne CRUD methods
This commit is contained in:
parent
911d8323b4
commit
93aefc36f5
|
@ -636,8 +636,7 @@ describe('relations - integration', function() {
|
||||||
function(err, group) {
|
function(err, group) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
test.group = group;
|
test.group = group;
|
||||||
group.cover.build({ url: 'http://image.url' });
|
done();
|
||||||
group.save(done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -645,6 +644,19 @@ describe('relations - integration', function() {
|
||||||
this.app.models.group.destroyAll(done);
|
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) {
|
it('includes the embedded models', function(done) {
|
||||||
var url = '/api/groups/' + this.group.id;
|
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() {
|
describe('embedsMany', function() {
|
||||||
|
|
Loading…
Reference in New Issue