Reputation: 137
i am having the following problem: i want to test the logout action of my controller. before that i am calling the login method of my controller which both redirect to the same page. now I am getting the following error message:
groovy.grails.web.servlet.mvc.exceptions.CannotRedirectException: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.
i do understand the problem, however all suggested solutions (calling the reset() method; calling GrailsWebUtil.bindMockWebRequest()) do not work.
i am doing integration testing and using the class ControllerUnitTestCase.
any suggestions? thanks dominik
Upvotes: 1
Views: 874
Reputation: 137
OK, I found the answer(s):
I forgot to call the setUp from the super class:
@Before
void setUp() {
super.setUp()
You cannot call reset() if you want to keep your session because it also clears your session. Call instead:
redirectArgs.clear()
Cheers, Dominik
Upvotes: 3