Skip to content

Commit e763ab2

Browse files
committed
fix for GRAILS-6561 "mockDomain and generator:assigned not working"
1 parent 61f14d5 commit e763ab2

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
@@ -735,7 +735,13 @@ class MockUtils {
735735
def properties = Introspector.getBeanInfo(clazz).propertyDescriptors
736736
def mapping = evaluateMapping(clazz)
737737

738-
boolean isInsert = !delegate.id
738+
boolean isInsert
739+
if (mapping?.id?.generator == "assigned") {
740+
isInsert = !testInstances.contains(delegate)
741+
} else {
742+
isInsert = !delegate.id
743+
}
744+
739745
if(isInsert) {
740746
triggerEvent delegate, 'beforeInsert'
741747
if (!testInstances.contains(delegate)) {

0 commit comments

Comments
 (0)