Skip to content

Instantly share code, notes, and snippets.

@willryan
Created October 11, 2012 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willryan/3873734 to your computer and use it in GitHub Desktop.
Save willryan/3873734 to your computer and use it in GitHub Desktop.
Geb DB test helpers
abstract class MyBaseGebTest extends GebReportingTest {
SessionFactory sessionFactory = ApplicationHolder.application.mainContext.sessionFactory
def inTransaction(closure) {
inNewSession {
TransactionRunner.getInstance().runInNewTransaction(closure)
}
}
def inNewSession(closure) {
// GORM class is arbitrary, I just picked one of ours
MyModelClass.withNewSession { session ->
closure(session)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment