Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
Per a comment on Glen Smith's blog (http://blogs.bytecode.com.au/glen/2008/03/12/mockfor-march---unit-testing-grails-controllers.html):
I think we should have a new ControllerTestCase that has a method like
def withMockController(Class c, Closure c)
that does all of the setting up of params/flash/etc.
Then you could just do
withMockController(LoginController) {
def controller = new LoginController()
lc.login(goodUser)
assertEquals "glen", session.account.userId
assertEquals "/demo/", redirectParams.uri
assertNull flash.loginError
LoginCommand badUser = new LoginCommand(userId: 'glen', password: 'unlucky')
lc.login(badUser)
assertNull session.account
assertNotNull flash.loginError
}
Thoughts? JIRA issue? ![]()
Duplicate of
GRAILS-2630GRAILS-2630