Skip to content

Commit 1d385aa

Browse files
committed
fix for GRAILS-6561 "mockDomain and generator:assigned not working"
1 parent 9c15d2b commit 1d385aa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/java/grails/test/MockUtils.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,13 @@ class MockUtils {
738738
def properties = Introspector.getBeanInfo(clazz).propertyDescriptors
739739
def mapping = evaluateMapping(clazz)
740740

741-
boolean isInsert = !delegate.id
741+
boolean isInsert
742+
if (mapping?.id?.generator == "assigned") {
743+
isInsert = !testInstances.contains(delegate)
744+
} else {
745+
isInsert = !delegate.id
746+
}
747+
742748
if(isInsert) {
743749
triggerEvent delegate, 'beforeInsert'
744750
if (!testInstances.contains(delegate)) {

0 commit comments

Comments
 (0)