Skip to content

Instantly share code, notes, and snippets.

@alvarosanchez
Last active August 29, 2015 14:02
Show Gist options
  • Save alvarosanchez/2aa7f59d5859b664d5b4 to your computer and use it in GitHub Desktop.
Save alvarosanchez/2aa7f59d5859b664d5b4 to your computer and use it in GitHub Desktop.
package com.odobo.gr8conf
import grails.rest.RestfulController
import grails.transaction.Transactional
@Transactional(readOnly = true)
class CategoryController extends RestfulController {
static responseFormats = ['json', 'xml']
CategoryController() {
super(Category)
}
}
class CategorySpec extends Specification {
@Shared
RESTClient restClient = new RESTClient("http://localhost:8080/restful-gr8conf-2014")
def "it returns just the categories of a game when is a nested resource"() {
when:
Response response = restClient.get(path: "/games/5/categories", accept: ContentType.JSON)
println response.json
then:
response.json.size() == 2
}
}
package com.odobo.gr8conf
import grails.rest.RestfulController
import grails.transaction.Transactional
@Transactional(readOnly = true)
class GameController extends RestfulController {
static responseFormats = ['json', 'xml']
GameController() {
super(Game)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment