Skip to content

Commit

Permalink
cleanup and fix tests. merge into all spock tests
Browse files Browse the repository at this point in the history
  • Loading branch information
basejump authored and sronderos committed Apr 18, 2013
1 parent ffef494 commit a20cd1b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 68 deletions.
34 changes: 0 additions & 34 deletions test/integration/demo/AnotherDemoServiceTests.groovy

This file was deleted.

34 changes: 0 additions & 34 deletions test/integration/demo/DemoServiceTests.groovy

This file was deleted.

63 changes: 63 additions & 0 deletions test/integration/demo/ScopedServicesSpec.groovy
@@ -0,0 +1,63 @@
package demo

import grails.plugin.spock.IntegrationSpec
import grails.plugin.multitenant.core.Tenant
/**
* Mostly as a smoke test to detect if any multi-tenant
* code affects regular domain classes.
* @author Kim A. Betti
*/
class ScopedServicesSpec extends IntegrationSpec {

def demoService
def anotherDemoService

def "tenant scope is working from config"() {
given: "each tenant set a val on service"
Tenant.withTenantId 1, {
assert "none" == demoService.touchedByTenant
demoService.touchedByTenant = "Tenant-1"
}

Tenant.withTenantId 2, {
assert "none" == demoService.touchedByTenant
demoService.touchedByTenant = "Tenant-2"
}

expect: "we should get values that were set"
Tenant.withTenantId 1, {
println demoService.touchedByTenant
"Tenant-1" == demoService.touchedByTenant
}
Tenant.withTenantId 2, {
println demoService.touchedByTenant
"Tenant-2" == demoService.touchedByTenant
}
}

def "tenant scope is working in service"() {
given: "each tenant set a val on service"
Tenant.withTenantId 1, {
assert "none" == anotherDemoService.touchedByTenant
anotherDemoService.touchedByTenant = "Tenant-1"
}

Tenant.withTenantId 2, {
assert "none" == anotherDemoService.touchedByTenant
anotherDemoService.touchedByTenant = "Tenant-2"
}

expect: "we should get values that were set"
Tenant.withTenantId 1, {
println anotherDemoService.touchedByTenant
"Tenant-1" == anotherDemoService.touchedByTenant
}
Tenant.withTenantId 2, {
println anotherDemoService.touchedByTenant
"Tenant-2" == anotherDemoService.touchedByTenant
}
}



}

0 comments on commit a20cd1b

Please sign in to comment.