Skip to content

Instantly share code, notes, and snippets.

@Omnipresent
Created May 18, 2013 14:18
Show Gist options
  • Save Omnipresent/5604559 to your computer and use it in GitHub Desktop.
Save Omnipresent/5604559 to your computer and use it in GitHub Desktop.
def save() {
request.withFormat {
json {
println "came here"
render params?.colors?.myParam
}
html {
render "html"
}
}
}
//test
def "js test" () {
given:
request.contentType = "application/json"
controller.request.content = "{colors: {myParam: 'a value', param2: 'value 2'}}"
when:
controller.save()
then:
controller.response.status == 200
response.contentAsString == "a value"
}
//test output
response.contentAsString == "a value"
| | |
| null false
//However, when request is initiated with RESTConsole with same string put in the RAW body then the response is correct ('a value')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment