diff --git a/core/client/models/tag.js b/core/client/models/tag.js index 879396a056..9803905487 100644 --- a/core/client/models/tag.js +++ b/core/client/models/tag.js @@ -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; + } }); }()); diff --git a/core/server/api/tags.js b/core/server/api/tags.js index f73936585e..5cd7c4d502 100644 --- a/core/server/api/tags.js +++ b/core/server/api/tags.js @@ -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() }; }); } }; diff --git a/core/test/functional/routes/api/tags_test.js b/core/test/functional/routes/api/tags_test.js index 2fb5155c97..b8c3554a72 100644 --- a/core/test/functional/routes/api/tags_test.js +++ b/core/test/functional/routes/api/tags_test.js @@ -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(); }); }); diff --git a/core/test/integration/api/api_tags_spec.js b/core/test/integration/api/api_tags_spec.js index dd34a975ac..4754f305b9 100644 --- a/core/test/integration/api/api_tags_spec.js +++ b/core/test/integration/api/api_tags_spec.js @@ -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); });