Permalink
Browse files

fix for GRAILS-3314

  • Loading branch information...
graemerocher committed Jul 21, 2009
1 parent 9cb23f5 commit 01c62367ddee0408f30a2639aefbf06a1ab8a023
@@ -406,7 +406,7 @@ private Object autoCreatePropertyIfPossible(BeanWrapper bean, String propertyNam
Object val = bean.isReadableProperty(propertyName) ? bean.getPropertyValue(propertyName) : null;
LOG.debug("Checking if auto-create is possible for property ["+propertyName+"] and type ["+type+"]");
- if(type != null && val == null && GroovyObject.class.isAssignableFrom(type)) {
+ if(type != null && val == null && DomainClassArtefactHandler.isDomainClass(type)) {
if(!shouldPropertyValueSkipAutoCreate(propertyValue) && isNullAndWritableProperty(bean, propertyName)) {
Object created = autoInstantiateDomainInstance(type);
@@ -0,0 +1,42 @@
+package org.codehaus.groovy.grails.web.binding
+
+import org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerTests
+
+/**
+ * @author Graeme Rocher
+ * @since 1.1
+ */
+
+public class EnumBindingTests extends AbstractGrailsControllerTests{
+
+ protected void onSetUp() {
+ gcl.parseClass('''
+import grails.persistence.*
+
+@Entity
+class StatusTransition {
+ String title
+ Status status
+}
+enum Status {
+ OPEN, IN_PROGRESS, ON_HOLD, DONE
+}
+
+class StatusController {
+ def bindMe = {
+ [statusTransition:new StatusTransition(title:"blah", status:Status.OPEN)]
+ }
+}
+''')
+ }
+
+
+ void testBindEnumInConstructor() {
+ def ctrl = ga.getControllerClass("StatusController").newInstance()
+
+ def model = ctrl.bindMe()
+
+ assertEquals "blah", model.statusTransition.title
+ assertEquals "OPEN", model.statusTransition.status.toString()
+ }
+}

0 comments on commit 01c6236

Please sign in to comment.