GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / web / taglib / LinkRenderingTagLib2Tests.groovy
blob08ede27cb17122d00f7f5bbd4d4bfd8979a2e6bc
1 package org.codehaus.groovy.grails.web.taglib;
3 import org.codehaus.groovy.runtime.InvokerHelper
4 import org.codehaus.groovy.grails.commons.*
6 class LinkRenderingTagLib2Tests extends AbstractGrailsTagTests {
8 void onInit() {
9 def mappingClass = gcl.parseClass('''
10 class TestUrlMappings {
11 static mappings = {
12 "/$id?"{
13 controller = "content"
14 action = "view"
17 "/$dir/$id"{
18 controller = "content"
19 action = "view"
23 ''')
25 grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, mappingClass)
28 void testLinkWithOnlyId() {
29 def template = '<g:link id="competition">Enter</g:link>'
31 assertOutputEquals('<a href="/competition">Enter</a>', template)
34 void testLinkWithOnlyIdAndAction() {
35 def template = '<g:link id="competition" controller="content" action="view">Enter</g:link>'
37 assertOutputEquals('<a href="/competition">Enter</a>', template)
40 void assertOutputEquals(expected, template, params = [:]) {
41 def engine = appCtx.groovyPagesTemplateEngine
43 assert engine
44 def t = engine.createTemplate(template, "test_"+ System.currentTimeMillis())
46 def w = t.make(params)
48 def sw = new StringWriter()
49 def out = new PrintWriter(sw)
50 webRequest.out = out
51 w.writeTo(out)
53 assertEquals expected, sw.toString()