Permalink
Browse files

* Fixes unit tests failing from 2.0 upgrade

  • Loading branch information...
1 parent ee92631 commit b77927a31824df4d691ab8bb95c14861e928d4c3 @rkrombho rkrombho committed Jan 24, 2012
@@ -1,7 +1,6 @@
package org.cotabo
import grails.plugins.springsecurity.Secured
-import org.codehaus.groovy.grails.commons.ConfigurationHolder as grailsConfig
import org.xml.sax.SAXParseException
@@ -12,6 +11,7 @@ class BoardController {
def boardUpdateService
def exportService
def importService
+ def grailsApplication
static allowedMethods = [save: "POST", update: "POST", delete: "GET", importBoards: ["GET", "POST"]]
@@ -26,7 +26,7 @@ class BoardController {
@Secured(['ROLE_ADMIN'])
def export = {
- response.contentType = grailsConfig.config.grails.mime.types['xml']
+ response.contentType = grailsApplication.config.grails.mime.types['xml']
response.setHeader("Content-disposition", "attachment; filename=boards.xml")
def stream = response.outputStream
@@ -74,8 +74,8 @@ class BoardController {
}
return [
boardInstance: boardInstance,
- colors:grailsConfig.config.taskboard.colors,
- priorities:grailsConfig.config.taskboard.priorities,
+ colors:grailsApplication.config.taskboard.colors,
+ priorities:grailsApplication.config.taskboard.priorities,
allUsers:User.list()
]
}
@@ -157,7 +157,7 @@ class BoardController {
else {
[
boardInstance: boardInstance,
- priorities:grailsConfig.config.taskboard.priorities
+ priorities:grailsApplication.config.taskboard.priorities
]
}
}
@@ -234,7 +234,7 @@ class BoardController {
else {
[
boardInstance: boardInstance,
- priorities:grailsConfig.config.taskboard.priorities
+ priorities:grailsApplication.config.taskboard.priorities
]
}
}
@@ -1,7 +1,8 @@
package org.cotabo
-import org.codehaus.groovy.grails.commons.ConfigurationHolder as grailsConfig
+
import grails.util.Environment
import groovy.time.TimeCategory
+import org.codehaus.groovy.grails.commons.ConfigurationHolder as grailsConfig
/**
* Represents a Task object on a Taskboard column.
@@ -13,8 +14,7 @@ import groovy.time.TimeCategory
class Task implements Rerenderable {
//This is determined at runtime by the related blocks
- static transients = ["blocked", "startDate", "rerenderAction"]
-
+ static transients = ["blocked", "startDate", "rerenderAction", "grailsApplication"]
//Relationships
static belongsTo = [ column : Column ]
//Blocked states
@@ -9,8 +9,8 @@ class AutoArchiveDoneJob {
def execute() {
// archive
- Task.getAll().each{task ->
- if(task.column.workflowEndColumn && new Date() - task.lastUpdated > grailsConfig.taskboard.default.autoarchive){
+ Task.list().each{task ->
+ if(task.column.workflowEndColumn && new Date() - task.lastUpdated > grailsConfig.config.taskboard.default.autoarchive){
task.archived = true;
task.save(flush:true); //TODO: bulk update/flush
}
@@ -1,10 +1,10 @@
package org.cotabo
import grails.test.*
-import org.codehaus.groovy.grails.commons.ConfigurationHolder as grailsConfig
class TaskIntegrationTests extends GrailsUnitTestCase {
def rerenderService
+ def grailsApplication
protected void setUp() {
super.setUp()
@@ -29,7 +29,7 @@ class TaskIntegrationTests extends GrailsUnitTestCase {
creator: user,
column: col,
priority: 'Critical',
- color: grailsConfig.config.taskboard.colors[0]
+ color: grailsApplication.config.taskboard.colors[0]
] as Task
col.addToTasks(newtask)
@@ -6,6 +6,14 @@ import grails.test.*
class AutoArchiveDoneJobTests extends TaskBoardUnitTest {
protected void setUp() {
super.setUp()
+ mockConfig '''
+ taskboard.colors = ['#fafaa8', '#faaca8', '#85fd81', '#81b6fd']
+ taskboard.default.colors = '#f9f21a'
+ taskboard.priorities = ['Critical', 'Major', 'Normal', 'Low']
+ taskboard.default.priority = 'Normal'
+ taskboard.default.autoarchive = 30
+ '''
+
}
protected void tearDown() {
@@ -28,6 +36,8 @@ class AutoArchiveDoneJobTests extends TaskBoardUnitTest {
priority: 'Critical',
lastUpdated: new Date().minus(31)
)
+ task.validate()
+ task.errors.allErrors.each {println it}
assertTrue task.validate()
assertNotNull task.save()
@@ -3,8 +3,10 @@ package org.cotabo
import grails.test.*
import org.codehaus.groovy.grails.plugins.codecs.HTMLCodec
+import grails.test.mixin.*
-class BoardTagLibTests extends TagLibUnitTestCase {
+@TestFor(BoardTagLib)
+class BoardTagLibTests {
protected void setUp() {
super.setUp()
mockTagLib(BoardTagLib)
@@ -16,13 +18,16 @@ class BoardTagLibTests extends TagLibUnitTestCase {
void testModal() {
def expected = """
+
<div id="delete_dialog" class="modal hide">
<div class="modal-header">
<a href="#" class="close">&times;</a>
<h3>Delete Board</h3>
</div>
<div class="modal-body">
+
<p>Do you really want to delete this board?</p>
+
</div>
<div class="modal-footer">
<a href="#" class="btn primary">Delete</a>
@@ -48,17 +53,15 @@ class BoardTagLibTests extends TagLibUnitTestCase {
\$('#delete_dialog').modal({backdrop:true, keyboard:true, show:true});
\$('#delete_dialog').modal('hide');
});
- </script>"""
+ </script>
+ """
- def tb = new BoardTagLib()
- tb.modal([
- id: "delete_dialog",
- header:"Delete Board",
- primary: "Delete",
- secondary: "Cancel"
- ], {'<p>Do you really want to delete this board?</p>'})
-
- assertEquals expected, tb.out.toString()
+ def tag = """
+ <tb:modal id="delete_dialog" header="Delete Board" primary="Delete" secondary="Cancel">
+ <p>Do you really want to delete this board?</p>
+ </tb:modal>
+ """
+ assertEquals expected, applyTemplate(tag)
}
}

0 comments on commit b77927a

Please sign in to comment.