Skip to content

Instantly share code, notes, and snippets.

@johnrengelman
Created October 2, 2012 22:19
Show Gist options
  • Save johnrengelman/3823684 to your computer and use it in GitHub Desktop.
Save johnrengelman/3823684 to your computer and use it in GitHub Desktop.
Set a hasMany collection on a domain object using BuildTestsData
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