Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrading to grails 2.1 adding spock test for EventService
- Loading branch information
1 parent
2d9155b
commit bce33bf
Showing
7 changed files
with
78 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#Grails Metadata file | ||
#Tue Mar 13 21:35:57 EDT 2012 | ||
app.grails.version=2.0.1 | ||
#Mon Aug 06 11:52:08 EDT 2012 | ||
app.grails.version=2.1.0 | ||
app.name=google-calendar | ||
app.servlet.version=2.5 | ||
app.version=0.1 | ||
plugins.cloud-foundry=1.2.1 | ||
plugins.cloud-foundry=1.2.2 | ||
plugins.spock=0.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.craigburke | ||
|
||
import grails.test.mixin.* | ||
import grails.plugin.spock.* | ||
import spock.lang.* | ||
|
||
import org.joda.time.* | ||
import static org.joda.time.DateTimeConstants.* | ||
|
||
@TestFor(EventService) | ||
@Mock(Event) | ||
class EventServiceSpec extends UnitSpec { | ||
|
||
@Shared DateTime now | ||
@Shared DateTime mondayNextWeek | ||
@Shared DateTime wednesdayNextWeek | ||
@Shared DateTime fridayNextWeek | ||
@Shared DateTime mondayAfterNext | ||
|
||
@Shared Event mwfEvent | ||
|
||
def setupSpec() { | ||
now = new DateTime() | ||
mondayNextWeek = new DateTime().plusWeeks(1).withDayOfWeek(MONDAY).withTime(0,0,0,0) | ||
wednesdayNextWeek = mondayNextWeek.withDayOfWeek(WEDNESDAY) | ||
fridayNextWeek = mondayNextWeek.withDayOfWeek(FRIDAY) | ||
mondayAfterNext = mondayNextWeek.plusWeeks(1) | ||
|
||
mwfEvent = new Event( | ||
title: 'Repeating MWF Event', | ||
startTime: mondayNextWeek.toDate(), | ||
endTime: mondayNextWeek.plusHours(1).toDate(), | ||
location: "Regular location", | ||
recurType: EventRecurType.WEEKLY, | ||
isRecurring: true, | ||
recurDaysOfWeek: [MONDAY, WEDNESDAY, FRIDAY] | ||
) | ||
|
||
} | ||
|
||
@Unroll("next occurance of weekly event after #afterDate") | ||
def "next occurrence of a weekly event without excluded days"() { | ||
expect: | ||
service.findNextOccurrence(event, afterDate.toDate()) == expectedResult.toDate() | ||
|
||
where: | ||
event | afterDate | expectedResult | ||
mwfEvent | now | mondayNextWeek | ||
mwfEvent | mondayNextWeek | wednesdayNextWeek | ||
mwfEvent | wednesdayNextWeek | fridayNextWeek | ||
} | ||
|
||
@Unroll("next occurence of weekly event with exclusion after #afterDate") | ||
def "test exclusion of next monday"() { | ||
setup: | ||
mwfEvent.addToExcludeDays(mondayNextWeek.toDate()) | ||
|
||
expect: | ||
service.findNextOccurrence(event, afterDate.toDate()) == expectedResult.toDate() | ||
|
||
|
||
where: | ||
event | afterDate | expectedResult | ||
mwfEvent | now | wednesdayNextWeek | ||
mwfEvent | mondayNextWeek | wednesdayNextWeek | ||
mwfEvent | wednesdayNextWeek | fridayNextWeek | ||
|
||
} | ||
|
||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.