@@ -3,14 +3,10 @@ package grails.test.mixin
33import grails.artefact.Artefact
44import grails.rest.RestfulController
55import grails.test.mixin.web.UrlMappingsUnitTestMixin
6- import grails.web.Action
7- import junit.framework.AssertionFailedError
86import junit.framework.ComparisonFailure
9-
107import org.junit.Test
118import org.springframework.web.context.WebApplicationContext
129import spock.lang.Issue
13-
1410/**
1511 * Tests for the UrlMappingsTestMixin class
1612 */
@@ -157,6 +153,19 @@ class UrlMappingsTestMixinTests {
157153 }
158154 }
159155
156+ @Test
157+ void testMethodMappings () {
158+ mockController(UserController )
159+ mockUrlMappings(MethodTestUrlMappings )
160+
161+ request. method = ' GET'
162+ assertUrlMapping(' /users/timmy' , controller : ' user' , action : ' show' , method : ' get' ) { name = ' timmy' }
163+ assertUrlMapping(' /users' , controller : ' user' , action : ' list' , method : ' get' )
164+
165+ request. method = ' PUT'
166+ assertUrlMapping(' /users/timmy' , controller : ' user' , action : ' update' , method : ' put' ) { name = ' timmy' }
167+ }
168+
160169 @Test
161170 @Issue (' https://github.com/grails/grails-core/issues/9065' )
162171 void testResourcesUrlMapping () {
@@ -212,6 +221,9 @@ class GrailsUrlMappingsTestCaseFakeController {
212221@Artefact (" Controller" )
213222class UserController {
214223 def publicProfile () {}
224+ def update () {}
225+ def show () {}
226+ def list () {}
215227}
216228
217229class MyUrlMappings {
@@ -250,6 +262,14 @@ class GRAILS9110UrlMappings {
250262 }
251263}
252264
265+ class MethodTestUrlMappings {
266+ static mappings = {
267+ " /users/$name " (controller : ' user' , action : ' update' , method : ' put' )
268+ " /users/$name " (controller : ' user' , action : ' show' , method : ' get' )
269+ " /users" (controller : ' user' , action : ' list' , method : ' get' )
270+ }
271+ }
272+
253273@Artefact (" Controller" )
254274class PersonController extends RestfulController<String > {
255275 PersonController () {
0 commit comments