Skip to content

Commit 4380949

Browse files
committed
add test for @AutoTimestamp
1 parent 8b649df commit 4380949

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

grails-data-mongodb/core/src/test/groovy/org/grails/datastore/gorm/mongo/BeforeUpdatePropertyPersistenceSpec.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.grails.datastore.gorm.mongo
2020

21+
import grails.gorm.annotation.AutoTimestamp
2122
import grails.persistence.Entity
2223
import org.apache.grails.data.mongo.core.GrailsDataMongoTckManager
2324
import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
@@ -132,11 +133,13 @@ class BeforeUpdatePropertyPersistenceSpec extends GrailsDataTckSpec<GrailsDataMo
132133
user.random == "Not Updated"
133134
user.dateCreated != null
134135
user.lastUpdated != null
136+
user.modified != null
135137

136138
when: "The user's name is updated"
137139
sleep 100 // ensure lastUpdated differs
138140
def previousRandom = user.random
139141
def previousLastUpdated = user.lastUpdated
142+
def previousModified = user.modified
140143
user.name = "Bob"
141144
user.save(flush: true)
142145
manager.session.clear()
@@ -149,6 +152,7 @@ class BeforeUpdatePropertyPersistenceSpec extends GrailsDataTckSpec<GrailsDataMo
149152
user.random != "Not Updated"
150153
user.random.length() == 5
151154
user.lastUpdated > previousLastUpdated
155+
user.modified > previousModified
152156
}
153157
}
154158

@@ -180,9 +184,11 @@ class UserWithBeforeUpdateAndAutoTimestamp {
180184
String random
181185
Date dateCreated
182186
Date lastUpdated
187+
@AutoTimestamp Date modified
183188

184189
static constraints = {
185190
random nullable: true
191+
modified nullable: true
186192
}
187193

188194
def beforeInsert() {

0 commit comments

Comments
 (0)