Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added GSP tests for the course controller. This is preparing so that #6
can be tested similarly.
  • Loading branch information
stuart committed Apr 20, 2012
1 parent 05055ca commit 16e5b26
Showing 1 changed file with 99 additions and 0 deletions.
@@ -0,0 +1,99 @@
package uk.org.openmentor.pages;

import grails.test.*
import uk.org.openmentor.courseinfo.Course
import uk.org.openmentor.controller.CourseController

/**
* Integration tests for course GPS pages. These take a little setting up and getting used
* to, but when complete provide very good coverage of the application as a whole.
*
* @author morungos
*/
class CourseGroovyPagesTests extends GroovyPagesTestCase {

protected void setUp() {
super.setUp()
}

protected void tearDown() {
super.tearDown()
}

/**
* Test the course controller's ability to create a form for a new
* course.
*/
void testCourseCreate() {
def file = new File("grails-app/views/course/create.gsp")

def controller = new CourseController()
def model = controller.create()

def htmlString = applyTemplate(file.text, model)
def textString = (htmlString =~ /<[^>]+>/).replaceAll("")
}

/**
* Test the course controller's ability to list courses.
*/
void testCourseList() {
def file = new File("grails-app/views/course/list.gsp")

def controller = new CourseController()
def model = controller.list()

def htmlString = applyTemplate(file.text, model)
def textString = (htmlString =~ /<[^>]+>/).replaceAll("")

assertTrue(htmlString.contains("CM2006"))
}

/**
* Test the course controller's ability to offer a selection of courses.
*/
void testCourseSelect() {
def file = new File("grails-app/views/course/select.gsp")

def controller = new CourseController()
def model = controller.select()

def htmlString = applyTemplate(file.text, model)
def textString = (htmlString =~ /<[^>]+>/).replaceAll("")

assertTrue(htmlString.contains("CM2006"))
}

/**
* Test the submission controller's ability to edit a submission.
*/
void testCourseShow() {
def file = new File("grails-app/views/course/show.gsp")

def course = Course.findByCourseId("CM2006")
assertTrue course != null

def controller = new CourseController()
controller.params.id = course.courseId
def model = controller.show()

def htmlString = applyTemplate(file.text, model)
}


/**
* Test the submission controller's ability to edit a submission.
*/
void testCourseEdit() {
def file = new File("grails-app/views/course/edit.gsp")

def course = Course.findByCourseId("CM2006")
assertTrue course != null

def controller = new CourseController()
controller.params.id = course.courseId
def model = controller.edit()

def htmlString = applyTemplate(file.text, model)
}
}

0 comments on commit 16e5b26

Please sign in to comment.