Created
May 18, 2013 14:18
-
-
Save Omnipresent/5604559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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