Last active
December 16, 2015 20:05
-
-
Save ishults/ad09d1ae6cfd2f6feadd to your computer and use it in GitHub Desktop.
Case-insensitive criteria Spec
This file contains hidden or 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
class CriteriaIntegrationSpec extends IntegrationSpec { | |
void "Nested criteria property ordering should ignoreCase properly"() { | |
given: 'A parent class and its child classes' | |
Parent parent = new Parent().save() | |
Child child1 = new Child(age: 10, name: 'Apollo', parent: parent).save()//1 | |
Child child3 = new Child(age: 20, name: 'Zeus', parent: parent).save()//3 | |
Child child2 = new Child(age: 30, name: 'athena', parent: parent).save()//2 | |
when: 'a criteria call is ordered by a String property' | |
List names = Parent.createCriteria().list() { | |
createAlias('children', 'child') | |
eq('child.parent', parent) | |
gt('child.age', 5) | |
projections { | |
property('child.name') | |
} | |
order(Order.asc('child.name').ignoreCase()) | |
} | |
then: 'it sorts case-insensitively' | |
assert names == [ 'Apollo', 'athena', 'Zeus' ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment