Skip to content
Browse files

GRAILS-11585 - test for improved allowedMethods handling

  • Loading branch information...
1 parent e7b8a91 commit 9f353a07f6458f4f8318bbda9d1369df2140f0e2 @jeffbrown jeffbrown committed Jul 16, 2014
View
5 ...itchen_sink_app/grails-app/controllers/commandobjects/CommandObjectsTestController.groovy
@@ -2,6 +2,7 @@ package commandobjects
class CommandObjectsTestController {
+ static allowedMethods = [updateGadget: 'POST']
def index = { }
def createCommand = {
@@ -57,12 +58,12 @@ class CommandObjectsTestController {
def updateGadget(Gadget gadget) {
if(gadget == null) {
- render 'gadget is null'
+ render "gadget is null, error count is ${errors?.errorCount}"
} else {
render "Gadget was loaded. id: ${gadget.id}, name: ${gadget.name}, age: ${gadget.age}"
}
}
-
+
def createGadget(Gadget gadget) {
if(gadget.save()) {
render "Create succeeded. id: ${gadget.id}, name: ${gadget.name}, age: ${gadget.age}"
View
18 apps/kitchen_sink_app/test/functional/commandobjects/CommandObjectsFunctionalTests.groovy
@@ -37,14 +37,28 @@ class CommandObjectsFunctionalTests extends functionaltestplugin.FunctionalTestC
}
assertStatus 200
assertContentContains 'Gadget was loaded. id: 1, name: DELTA, age: 42'
+
+ post '/commandObjectsTest/updateGadget?id=bogus&name=BETA'
+ assertStatus 200
+ assertContentContains 'gadget is null, error count is 1'
+
+ post '/commandObjectsTest/updateGadget?id=2112&name=BETA'
+ assertStatus 200
+ assertContentContains 'gadget is null, error count is 0'
+
+ get '/commandObjectsTest/updateGadget?id=bogus&name=BETA'
+ assertStatus 405
+
+ get '/commandObjectsTest/updateGadget?id=2112&name=BETA'
+ assertStatus 405
}
void testCommandObjectIdNotFound() {
- get '/commandObjectsTest/updateGadget?id=2112&name=BETA'
+ post '/commandObjectsTest/updateGadget?id=2112&name=BETA'
assertStatus 200
assertContentContains 'gadget is null'
}
-
+
void testConstraintsProperty() {
get '/commandObjectsTest/testConstraintsProperty'
assertStatus 200

0 comments on commit 9f353a0

Please sign in to comment.
Something went wrong with that request. Please try again.