Changeset 1445
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy
r1440 r1445 141 141 Assay assay = Assay.get(params.assayId) 142 142 143 // check if assay exists 143 144 if (!assay) { 144 145 flash.errorMessage = "No assay found with id: $params.assayId." … … 159 160 } catch (Exception e) { 160 161 161 flash.errorMessage = e. toString()162 flash.errorMessage = e.cause?.message ?: e.message 162 163 redirect action: 'selectAssay' 163 164 -
trunk/grails-app/views/assay/selectAssay.gsp
r1430 r1445 14 14 function updateAssay(jsonData, selectID) { 15 15 var a = eval(jsonData); 16 var sel = $('#'+selectID).empty() 16 var sel = $('#'+selectID).empty(); 17 17 18 18 $(a).each(function(i, el){ 19 sel.append($("<option></option>").attr("value",el.id).text(el.name)) ;20 }) ;19 sel.append($("<option></option>").attr("value",el.id).text(el.name)) 20 }) 21 21 } 22 23 $(document).ready(function(){ 24 // trigger change event to load assay based on currently selected study. 25 // After pressing 'Back', the browser may use last selected study. 26 $('#study').change() 27 28 }) 22 29 </script> 23 30 </head> … … 27 34 </div> 28 35 <g:form name="assaySelect" action="exportAssayAsExcel"> 29 <g:select optionKey="id" optionValue="title" name="studyId" from="${userStudies}" 30 onChange="${remoteFunction(controller:'study',action:'ajaxGetAssays',params:'\'id=\'+escape(this.value)',onComplete: 'updateAssay(XMLHttpRequest.responseText, \'assay\')')}"/> 31 <g:select optionKey="id" name="assayId" id="assay" from="${assays}"/> 36 <g:select optionKey="id" optionValue="title" name="studyId" from="${userStudies}" id="study" 37 onChange="${remoteFunction(controller:'study',action:'ajaxGetAssays',params:'\'id=\'+escape(this.value)',onComplete: 'updateAssay(XMLHttpRequest.responseText, \'assay\')')}"/> 38 <g:select optionKey="id" name="assayId" id="assay" from=""/> 39 %{--<g:select optionKey="id" name="assayId" id="assay" from="${assays}"/>--}% 32 40 <g:submitButton name="submit" value="Submit"/> 33 41 </g:form> -
trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy
r1430 r1445 18 18 protected void setUp() { 19 19 super.setUp() 20 mockDomain(Assay, [new Assay(id:1)]) 20 21 } 21 22 … … 25 26 26 27 void testWrongAssayID() { 27 mockParams.assayId = 128 mockParams.assayId = 3 28 29 29 30 controller.exportAssayAsExcel() … … 34 35 35 36 void testExceptionHandling() { 37 mockParams.assayId = 1 38 39 controller.metaClass.'grailsApplication' = [ 40 config: [modules: [metabolomics: [url: 'www.ab.com']]] 41 ] 42 36 43 controller.assayService = [ 37 collectAssayData:{a, b -> throw new Exception('msg1')}, 38 exportColumnWiseDataToExcelFile:{a, b -> throw new Exception('msg2')} 44 45 collectAssayData: {a, b -> def e = new Exception('msga'); e.metaClass.cause = new Exception('msg1'); throw e }, 46 exportColumnWiseDataToExcelFile: {a, b -> def e = new Exception('msgb'); e.metaClass.cause = new Exception('msg2'); throw e } 47 39 48 ] 49 40 50 controller.exportAssayAsExcel() 41 51 42 52 assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs 43 assertEquals 'Error message', ' java.lang.Exception:msg1', mockFlash.errorMessage53 assertEquals 'Error message', 'msg1', mockFlash.errorMessage 44 54 45 55 controller.assayService.collectAssayData = {a, b -> true} … … 47 57 48 58 assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs 49 assertEquals 'Error message', ' java.lang.Exception:msg2', mockFlash.errorMessage59 assertEquals 'Error message', 'msg2', mockFlash.errorMessage 50 60 51 61 }
Note: See TracChangeset
for help on using the changeset viewer.