Created
October 2, 2012 22:19
-
-
Save johnrengelman/3823684 to your computer and use it in GitHub Desktop.
Set a hasMany collection on a domain object using BuildTestsData
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
class Foo { | |
Bar bar | |
} | |
class Bar { | |
static belongsTo = Foo | |
static hasMany = [bazzes: Baz] | |
} | |
class Baz { | |
static belongsTo = [bar: Bar] | |
} | |
TestDataConfig.groovy | |
'Foo' { | |
bar = { | |
def b = Bar.buildWithoutSave() | |
3.times { | |
b.addToBazzes(new Baz()) | |
} | |
b | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment