diff --git a/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js b/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js index 71c55894..5ab2a83a 100644 --- a/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js +++ b/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js @@ -93,7 +93,7 @@ profileEditor.controller("AttachmentUploadController", function (profileService, if (self.categories == null) { profileService.getCategories().then(function (data) { - self.categories = data; + self.categories = data.resp; }); } diff --git a/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy b/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy index 2dd9fda9..025b35a0 100644 --- a/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy +++ b/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy @@ -361,7 +361,7 @@ class OpusController extends OpusBaseController { def getCategories() { def result = profileService.getCategories() - handle result + render result as JSON } @Secured(role = ROLE_PROFILE_ADMIN) diff --git a/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy b/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy index 86d17a98..13784a1a 100644 --- a/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy +++ b/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy @@ -179,7 +179,8 @@ class ApiControllerSpec extends Specification implements ControllerUnitTest> [[key: 'key1', title: 'title1'],[key: 'key2', title: 'title2'],[key: 'key3', title: 'title3']] + + when: + controller.getCategories() + + then: + assert response.json.size() == 3 + assert response.json.toString().contains("key1") + assert response.json.toString().contains("key2") + assert response.json.toString().contains("key3") + } }