Permalink
Browse files

fix recursive prefix of spotless mind

  • Loading branch information...
fabiooshiro committed Apr 21, 2013
1 parent 7098cf4 commit 5b2ede34c14ba52011de463db46232ac67beb7e3
@@ -4,9 +4,15 @@ class Artist {
String name
+ City city
+
String toString(){
name
}
static hasMany = [portraits: Portrait]
+
+ static constraints = {
+ city nullable: true
+ }
}
@@ -0,0 +1,11 @@
+package plastic.criteria
+
+class City{
+
+ String name
+
+ String toString(){
+ name
+ }
+
+}
@@ -585,4 +585,30 @@ class CriteriaDocTests {
}
assert 0 == rs.size()
}
+
+ // next release 0.9
+ void test_nested_object(){
+ def paris = new City(name: 'Paris').save()
+ def monet = new Artist(name: 'Monet', city: paris).save()
+ new Portrait(artist: monet, name: 'Soleil levant 1').save()
+
+ def rio = new City(name: 'Rio de Janeiro').save()
+ def portinari = new Artist(name: 'Portinari', city: rio).save()
+ new Portrait(artist: portinari, name: 'Retirantes').save()
+ new Portrait(artist: portinari, name: 'Paisagem de Brodowski').save()
+
+ def diCavalcanti = new Artist(name: 'Di Cavalcanti', city: rio).save()
+ new Portrait(artist: diCavalcanti, name: 'Autorretrato Com Mulata').save()
+
+ def rs = Portrait.withCriteria{
+ artist{
+ city{
+ eq('name', 'Rio de Janeiro')
+ }
+ }
+ order('name', 'asc')
+ }
+ assert 3 == rs.size()
+ assert ['Autorretrato Com Mulata', 'Paisagem de Brodowski', 'Retirantes'] == rs.name
+ }
}
@@ -130,7 +130,7 @@ class PlasticCriteria {
_leCriticalList.ls.add([criteriaName: name, prop: _prefix + args[0], val: ((args.length > 1) ? args[1] : 'null'), opt: ((args.length > 2) ? args[2] : [:])])
}else{
if(!args || !(args[0] instanceof Closure)) throw new MissingMethodException(name, this.class, args)
- def fc = new PlasticCriteria(_clazz, name)
+ def fc = new PlasticCriteria(_clazz, _prefix + name)
args[0].resolveStrategy = Closure.DELEGATE_FIRST
args[0].delegate = fc
args[0]()
@@ -4,7 +4,7 @@ import static plastic.criteria.PlasticCriteria.*
import org.junit.Before
-@Mock([Artist, Portrait])
+@Mock([Artist, City, Portrait])
class PlasticCriteriaTests extends CriteriaDocTests{
@Before

0 comments on commit 5b2ede3

Please sign in to comment.