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
Showing
3 changed files
with
44 additions
and
0 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
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,16 @@ | ||
package org.wherecaniget | ||
|
||
import org.zkoss.bind.annotation.Command | ||
import org.zkoss.bind.annotation.NotifyChange | ||
|
||
|
||
class StoreVM { | ||
def storeService | ||
def store | ||
|
||
@Command @NotifyChange(['store']) | ||
def save(){ | ||
store = storeService.create(store) | ||
} | ||
} | ||
|
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,27 @@ | ||
package org.wherecaniget | ||
|
||
import static org.junit.Assert.* | ||
|
||
import grails.test.mixin.* | ||
import grails.test.mixin.support.* | ||
import org.junit.* | ||
|
||
@TestMixin(GrailsUnitTestMixin) | ||
@Mock([Store]) | ||
class StoreVMTests { | ||
|
||
@Before | ||
void setUp() { | ||
} | ||
|
||
|
||
@Test | ||
void create_new_store() { | ||
StoreVM vm = new StoreVM() | ||
vm.storeService = [create: {[id: 1, name: 'Test Store']}] | ||
vm.save() | ||
|
||
assertNotNull vm.store.id | ||
assertEquals 'Test Store', vm.store.name | ||
} | ||
} |