Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for grails/grails-data-mapping#1064 #132

Open
wants to merge 1 commit into
base: 6.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#gormVersion=6.1.11.BUILD-SNAPSHOT
gormVersion=6.1.11.RELEASE
gormVersion=6.1.12.BUILD-SNAPSHOT
#gormVersion=6.1.11.RELEASE
grailsVersion=3.2.11
groovyVersion=2.4.11
springBootVersion=1.5.18.RELEASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import grails.gorm.annotation.Entity
import grails.gorm.dirty.checking.DirtyCheck
import grails.gorm.transactions.Rollback
import org.grails.orm.hibernate.HibernateDatastore
import org.springframework.transaction.PlatformTransactionManager
import spock.lang.AutoCleanup
import spock.lang.Issue
import spock.lang.Shared
Expand All @@ -15,7 +14,7 @@ import spock.lang.Specification
*/
class HibernateDirtyCheckingSpec extends Specification {

@Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(Person)
@Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(Person, DirtyCheckingDummy)

@Rollback
@Issue('https://github.com/grails/grails-core/issues/10613')
Expand Down Expand Up @@ -75,6 +74,16 @@ class HibernateDirtyCheckingSpec extends Specification {


}

@Rollback
void "test dirtyness of new instances"() {
when:
DirtyCheckingDummy dummy = new DirtyCheckingDummy(name: "dummy").save failOnError: true, flush: true

then:
!dummy.hasChanged()
!dummy.dirty
}
}


Expand All @@ -100,4 +109,16 @@ class Person {
class Address {
String street
String zip
}

@Entity
class DirtyCheckingDummy {

String name

def beforeInsert() {
assert hasChanged()
assert !dirty
}

}