Skip to content

Commit

Permalink
Merge pull request #354 from matrei/matrei/fix-tests
Browse files Browse the repository at this point in the history
Fix tests for Grails 7
  • Loading branch information
codeconsole authored Sep 15, 2024
2 parents fe25282 + 5253cec commit 99dfa69
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 51 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ dependencies {

testImplementation 'org.javassist:javassist:3.29.0-GA'
testImplementation "org.apache.groovy:groovy-dateutil"
testImplementation "cglib:cglib-nodep:2.2.2"
testImplementation("org.jodd:jodd-wot:$joddWotVersion") {
exclude module: 'slf4j-api'
exclude module: 'asm'
}

testRuntimeOnly "net.bytebuddy:byte-buddy:$byteBuddyVersion"
}

tasks.withType(GroovyCompile).configureEach {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ grailsGradlePluginVersion=7.0.0-SNAPSHOT
grailsScaffoldingVersion=2.1.0
groovyVersion=4.0.23
joddWotVersion=3.3.8
byteBuddyVersion=1.14.12
asciidoc=true
githubSlug=gpc/fields
githubBranch=master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.spockframework.util.VersionNumber
import org.springframework.beans.NotReadablePropertyException
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.PendingFeature
import spock.lang.Shared
import spock.lang.Unroll
import spock.util.environment.Jvm
Expand Down Expand Up @@ -362,6 +363,7 @@ class DomainClassPropertyAccessorSpec extends BuildsAccessorFactory {
"minor" | false // boolean properties are never considered required
}

@PendingFeature(reason = 'until domain class inheritance works in Groovy 4')
def 'the superclasses of #type.simpleName are #expected'() {
given:
def propertyAccessor = factory.accessorFor(type.getConstructor().newInstance(), path)
Expand All @@ -387,6 +389,7 @@ class DomainClassPropertyAccessorSpec extends BuildsAccessorFactory {
Employee | 'name' | [Person]
}

@IgnoreIf({ VersionNumber.parse(Jvm.current.javaVersion).major >= 17 })
void 'the superclasses of Person.#path are #expected'() {
given:
def propertyAccessor = factory.accessorFor(person, path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class FormFieldsTemplateServiceSpec extends BuildsAccessorFactory implements Ser
render(template: template.path) == 'DEFAULT FIELD TEMPLATE'
}

@PendingFeature(reason = 'until domain class inheritance works in Groovy 4')
def "resolves template for superclass property"() {
given:
views["/_fields/default/_wrapper.gsp"] = 'DEFAULT FIELD TEMPLATE'
Expand Down
51 changes: 2 additions & 49 deletions src/test/groovy/grails/plugin/formfields/mock/Employee.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,13 @@ package grails.plugin.formfields.mock
import grails.persistence.Entity

@Entity
class Employee { // inheritance currently does not work in Grails 7 // extends Person {
// extended from Person - start
Salutation salutation
String name
String password
Gender gender
Date dateOfBirth
Address address
Map emails = [:]
boolean minor
Date lastUpdated
String excludedProperty
String displayFalseProperty
Boolean grailsDeveloper
Byte[] picture
byte[] anotherPicture
String biography

transient String transientText = "transient text"

static hasMany = [emails: String]
static embedded = ['address']

static constraints = {
salutation nullable: true
name blank: false
dateOfBirth nullable: true
address nullable: true
excludedProperty nullable: true
displayFalseProperty nullable: true, display: false
grailsDeveloper nullable: true
picture nullable: true
anotherPicture nullable: true
password password: true
biography nullable: true, widget: 'textarea'
}

static scaffold = [exclude: ['excludedProperty']]
// static transients = ['transientText']
def onLoad = {
println "loaded"
}
// extended from Person - finish

@Override
String toString() {
name
}
class Employee extends HomoSapiens {

int salary

int getYearlySalary() {
200 * salary
}

static transients = ['transientText','yearlySalary']
static transients = ['yearlySalary']
}
8 changes: 7 additions & 1 deletion src/test/groovy/grails/plugin/formfields/mock/Person.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ package grails.plugin.formfields.mock
import grails.persistence.Entity

@Entity
class Person {
class Person extends HomoSapiens {}

/*
Workaround for problem with domain inheritance in Groovy 4.
(Superclasses cannot be Gorm entities).
*/
class HomoSapiens {
Salutation salutation
String name
String password
Expand Down

0 comments on commit 99dfa69

Please sign in to comment.