Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fd89b7
commit e11436e
Showing
2 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
...e/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/TotalCountWithOrderSpec.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 org.codehaus.groovy.grails.orm.hibernate | ||
|
||
import grails.persistence.Entity | ||
|
||
/** | ||
* Tests usage of total count when an order by is used | ||
*/ | ||
class TotalCountWithOrderSpec extends GormSpec{ | ||
|
||
void "Test total with with order by"() { | ||
when:"A pagination query is used with order by" | ||
def criteria = Post.createCriteria() | ||
def results = criteria.list (max: 10, offset: 5) { | ||
order("dateCreated", "desc") | ||
} | ||
|
||
then:"Both total count and results work" | ||
results.size() == 0 | ||
results.totalCount == 0 | ||
} | ||
|
||
@Override | ||
List getDomainClasses() { | ||
[Post] | ||
} | ||
} | ||
@Entity | ||
class Post { | ||
|
||
String title | ||
Date dateCreated | ||
|
||
static constraints = { | ||
} | ||
} | ||
|