Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:grails/grails-core
- Loading branch information
Showing
8 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
36 changes: 36 additions & 0 deletions
36
...suite-web/src/test/groovy/org/codehaus/groovy/grails/web/pages/OptionalTagBodySpec.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.codehaus.groovy.grails.web.pages | ||
|
||
import grails.test.AbstractGrailsEnvChangingSpec | ||
|
||
import spock.lang.Specification | ||
import grails.test.mixin.TestFor | ||
import grails.util.Environment; | ||
import grails.artefact.Artefact | ||
|
||
|
||
@TestFor(CustomTagLib) | ||
class OptionalTagBodySpec extends AbstractGrailsEnvChangingSpec { | ||
def "Test that the existence of a body can be tested with groovy truth"(grailsEnv) { | ||
when: | ||
changeGrailsEnv(grailsEnv) | ||
def content = applyTemplate("<a:myBody />") | ||
def content2 = applyTemplate("<a:myBody>Hello</a:myBody>") | ||
then: | ||
content == 'nobody' | ||
content2 == 'Hello' | ||
where: | ||
grailsEnv << grailsEnvs | ||
} | ||
} | ||
@Artefact("TagLibrary") | ||
class CustomTagLib { | ||
static namespace = "a" | ||
|
||
def myBody = { attrs, body -> | ||
if(body) { | ||
out << body() | ||
} else { | ||
out << 'nobody' | ||
} | ||
} | ||
} |
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
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
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