GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / web / mapping / UrlMappingWithCustomValidatorTests.groovy
blobd6aedbc3980aa217110d5bd0167121e0a934d31d
1 /**
2 * @author Graeme Rocher
3 * @since 1.0
4 *
5 * Created: Jan 7, 2008
6 */
7 package org.codehaus.groovy.grails.web.mapping
9 import org.springframework.core.io.ByteArrayResource
10 import org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerTests
12 class UrlMappingWithCustomValidatorTests extends AbstractGrailsControllerTests {
13 def topLevelMapping = '''
14 mappings {
15 "/help/$path**"(controller : "wiki", action : "show", id : "1") {
16 constraints {
17 path(validator : { val, obj -> ! val.startsWith("js") })
21 '''
22 def UrlMappingsHolder holder
25 void setUp() {
26 super.setUp()
27 def res = new ByteArrayResource(topLevelMapping.bytes)
29 def evaluator = new DefaultUrlMappingEvaluator()
30 def mappings = evaluator.evaluateMappings(res)
32 holder = new DefaultUrlMappingsHolder(mappings)
35 void testMatchWithCustomValidator() {
36 def info = holder.match("/help/foo.html")
38 assert info
40 info = holder.match("/help/js/foo.js")
42 assert !info