forked from grails-plugins/grails-audit-logging-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuditColumnNamesSpec.groovy
39 lines (32 loc) · 1.04 KB
/
AuditColumnNamesSpec.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package test
import grails.core.GrailsApplication
import grails.test.mixin.integration.Integration
import grails.transaction.Rollback
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
@Integration
@Rollback
class AuditColumnNamesSpec extends Specification {
@Autowired
GrailsApplication grailsApplication
def setup() {
Planet.auditable = true
}
def "test that the actual table name is logged in audit table instead of the property name"() {
given:
grailsApplication.config.grails.plugin.auditLog.logColumnNameAsPropertyName = true
when:
new Planet(
name: "Earth",
star: 'Sun',
numOfSatellites: 1
).save(flush: true, failOnError: true)
then:
List<AuditTrail> trails = AuditTrail.findAllByClassName('test.Planet')
def titleTrail = trails.find { it.propertyName == 'PLANET_NAME' }
with(titleTrail) {
oldValue == null
newValue == 'Earth'
}
}
}