mercredi 28 janvier 2015

Grails- Web Flow Spring- redirection error in unit test

I want to test my web flow in the grails-app in unit-test. I got redirection error.


the code of the web-flow is:



def redesignSignup = {
redirect(action: "signupRedesign")
}

// Responsible for the new signup flow
def signupRedesignFlow = {
start {
on("yes").to"createAccount"
}
createAccount{
on("next"){
flow.step = 2
flash.name = "flash"}.to"congrats"
on("back"){}.to "start"
}

congrats {
redirect(controller: "connection", action: "details", params: [newUser: true])
}

}


he code of the unit-test is:



class WizardControllerSpec extends Specification {

def "test next"(){
// step1->step2
when:"user click yes in start"
then:"next page is create account"
assert "createAccount" == signupRedesignFlow.start.on.yes.to

when:"user click next in createAccount"
then:"next page is connectPeople"
assert "connectPeople" == signupRedesignFlow.createAccount.on.next.to


when:"user click next in invitePartners"
then:"next page is congrats"
assert "congrats" == signupRedesignFlow.invitePartners.on.next.to

}


The error I get is: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.CannotRedirectException: Cannot issue a redirect(..) here. A previous call to redirect(..)


**noticed that there is no test that even call the redirect in the congrats


Aucun commentaire:

Enregistrer un commentaire