All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.gorm.tests.AttachMethodSpec.groovy Maven / Gradle / Ivy

There is a newer version: 9.0.0-M2
Show newest version
package grails.gorm.tests

/**
 * @author graemerocher
 */
class AttachMethodSpec extends GormDatastoreSpec {

    void "Test attach method"() {
        given:
            def test = new Person(firstName:"Bob", lastName:"Builder").save()

        when:
            session.flush()

        then:
            session.contains(test) == true
            test.isAttached()
            test.attached

        when:
            test.discard()

        then:
            !session.contains(test)
            !test.isAttached()
            !test.attached

        when:
            test.attach()

        then:
            session.contains(test)
            test.isAttached()
            test.attached

        when:
            test.discard()

        then:
            test == test.attach()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy