Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case for #676 (GRAILS-11855). The fix is in grails-data-mapping.
- Loading branch information
1 parent
45e80e5
commit ae57f6c
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
grails-test-suite-persistence/src/test/groovy/grails/test/mixin/domain/SaveDomainSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package grails.test.mixin.domain | ||
|
||
import grails.persistence.Entity | ||
import grails.test.mixin.TestFor | ||
import spock.lang.Specification | ||
|
||
@TestFor(Person) | ||
class SaveDomainSpec extends Specification { | ||
|
||
void 'test dateCreated and lastUpdated populated'() { | ||
given: | ||
Person person = new Person(name: 'Bobby') | ||
|
||
when: | ||
person.save(flush: true) | ||
|
||
then: | ||
person.dateCreated != null | ||
person.lastUpdated != null | ||
person.dateCreated == person.lastUpdated | ||
|
||
when: | ||
person.name = 'Bobby Updated' | ||
person.save(flush: true) | ||
|
||
then: | ||
person.lastUpdated > person.dateCreated | ||
} | ||
} | ||
|
||
@Entity | ||
class Person { | ||
String name | ||
Date dateCreated | ||
Date lastUpdated | ||
} |