Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Before
- public void setUp() {
- super.setUp()
- flash = [ : ]
- AddressController.metaClass.getFlash= { -> flash }
- params = [ : ]
- AddressController.metaClass.getParams = { -> params }
- redirectParams = [ : ]
- AddressController.metaClass.'static'.redirect = { Map args -> redirectParams = args }
- renderParams= [ : ]
- AddressController.metaClass.render = { Map args -> renderParams = args }
- }
- if(!quoteInstance) {
- flash.message = "Quote not found with id ${params.id}"
- redirect(action:list)
- }
- else {
- return [ quoteInstance : quoteInstance ]
- }
- }
- params['id'] = 123 ;
- Quote.metaClass.static.get = { int id ->
- assertEquals params.id, id
- return null
- }
- QuoteController cc = new QuoteController()
- cc.edit()
- assertEquals 'Quote not found with id 123', flash.message
- assertEquals cc.list, redirectParams.action
- }
Add Comment
Please, Sign In to add comment