Skip to content

Commit 1ae17ca

Browse files
committed
Test for #9989
1 parent 1d24925 commit 1ae17ca

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

grails-core/src/test/groovy/grails/transaction/TransactionalTransformSpec.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,47 @@ import spock.lang.Specification
2121

2222
import javax.annotation.PostConstruct
2323
import javax.sql.DataSource
24+
import java.lang.reflect.Field
2425

2526
/**
2627
*/
2728
class TransactionalTransformSpec extends Specification {
2829

30+
@Issue('https://github.com/grails/grails-core/issues/9989')
31+
void "Test transactional transform when applied to inheritance"() {
32+
when: "A subclass subclasses a transactional service"
33+
Class dogService = new GroovyShell().evaluate('''
34+
import grails.transaction.*
35+
36+
@Transactional
37+
class MammalService {
38+
39+
def sound() {
40+
"unknown"
41+
}
42+
}
43+
44+
@Transactional
45+
class DogService extends MammalService {
46+
47+
@Override
48+
def sound() {
49+
"bark"
50+
}
51+
52+
}
53+
54+
DogService
55+
''')
56+
57+
def field = ReflectionUtils.findField(dogService, '$transactionManager')
58+
59+
then: "It implements TransactionManagerAware"
60+
TransactionManagerAware.isAssignableFrom(dogService)
61+
field.declaringClass.name == 'MammalService'
62+
63+
}
64+
2965
@Issue('https://github.com/grails/grails-core/issues/9837')
3066
void "Test @Rollback when applied to Spock specifications with closures combined with where queries"() {
3167
when: "A new instance of a class with a @Transactional method is created that subclasses another transactional class"

0 commit comments

Comments
 (0)