Created
October 1, 2012 10:34
-
-
Save jakubnabrdalik/3810821 to your computer and use it in GitHub Desktop.
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
def "created outlet insert command should have new account"() { | |
given: | |
setValidOutletInsertCommandParameters(controller) | |
userIsLoggedIn() | |
when: | |
controller.save() | |
then: | |
outletInsertCommandHasNewAccount() | |
} | |
private boolean outletInsertCommandHasNewAccount() { | |
def savedCommand = OutletInsertCommand.get(1) | |
savedCommand.mobileMoneyAccountNumber == '1000000000000' && savedCommand.accountType == CyclosAccountType.NOT_AGENT | |
} | |
def "should not create outlet, when creating outlet insert command"() { | |
given: | |
setValidOutletInsertCommandParameters(controller) | |
userIsLoggedIn() | |
when: | |
controller.save() | |
then: | |
Outlet.count() == 0 | |
OutletInsertCommand.count() == 1 | |
} | |
def "should notify accepters when creating outlet insert command"() { | |
given: | |
setValidOutletInsertCommandParameters(controller) | |
userIsLoggedIn() | |
when: | |
controller.save() | |
then: | |
1 * commandNotificationServiceMock.notifyAccepters(_) | |
} | |
private void userIsLoggedIn() { | |
securityServiceMock.getCurrentlyLoggedUser() >> user | |
} | |
private void setValidOutletInsertCommandParameters(def controller) { | |
def validParams = OutletFactory.validOutletParams | |
validParams.remove('mobileMoneyAccountNumber') | |
validParams.remove('accountType') | |
validParams.put('merchant.id', merchant.id) | |
controller.params.putAll(validParams) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment