0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #2626 from jgable/apiTagPrimaryDocument

Tag API: Primary Document Format
This commit is contained in:
Hannah Wolfe 2014-04-21 18:22:22 +02:00
commit 856bd17696
4 changed files with 12 additions and 7 deletions

View file

@ -3,6 +3,10 @@
'use strict';
Ghost.Collections.Tags = Ghost.ProgressCollection.extend({
url: Ghost.paths.apiRoot + '/tags/'
url: Ghost.paths.apiRoot + '/tags/',
parse: function (resp) {
return resp.tags;
}
});
}());

View file

@ -4,12 +4,11 @@ var dataProvider = require('../models'),
tags = {
// #### Browse
// **takes:** Nothing yet
browse: function browse() {
// **returns:** a promise for all tags which have previously been used in a json object
return dataProvider.Tag.findAll().then(function (result) {
return result.toJSON();
return { tags: result.toJSON() };
});
}
};

View file

@ -93,8 +93,9 @@ describe('Tag API', function () {
res.should.be.json;
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.should.have.length(6);
testUtils.API.checkResponse(jsonResponse[0], 'tag');
jsonResponse.tags.should.exist;
jsonResponse.tags.should.have.length(6);
testUtils.API.checkResponse(jsonResponse.tags[0], 'tag');
done();
});
});

View file

@ -33,8 +33,9 @@ describe('Tags API', function () {
it('can browse', function (done) {
TagsAPI.browse().then(function (results) {
should.exist(results);
results.length.should.be.above(0);
testUtils.API.checkResponse(results[0], 'tag');
should.exist(results.tags);
results.tags.length.should.be.above(0);
testUtils.API.checkResponse(results.tags[0], 'tag');
done();
}).then(null, done);
});