File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
grails-core/src/test/groovy/grails/transaction Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,47 @@ import spock.lang.Specification
2121
2222import javax.annotation.PostConstruct
2323import javax.sql.DataSource
24+ import java.lang.reflect.Field
2425
2526/**
2627 */
2728class 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"
You can’t perform that action at this time.
0 commit comments