Skip to content

Commit

Permalink
fix recursive prefix of spotless mind
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiooshiro committed Apr 21, 2013
1 parent 7098cf4 commit 5b2ede3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions grails-app/domain/plastic/criteria/Artist.groovy
Expand Up @@ -4,9 +4,15 @@ class Artist {

String name

City city

String toString(){
name
}

static hasMany = [portraits: Portrait]

static constraints = {
city nullable: true
}
}
11 changes: 11 additions & 0 deletions grails-app/domain/plastic/criteria/City.groovy
@@ -0,0 +1,11 @@
package plastic.criteria

class City{

String name

String toString(){
name
}

}
26 changes: 26 additions & 0 deletions src/groovy/plastic/criteria/CriteriaDocTests.groovy
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion src/groovy/plastic/criteria/PlasticCriteria.groovy
Expand Up @@ -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]()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/plastic/criteria/PlasticCriteriaTests.groovy
Expand Up @@ -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
Expand Down

0 comments on commit 5b2ede3

Please sign in to comment.