Skip to content

Commit

Permalink
Also test for empty RDATE and EXDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed Nov 30, 2024
1 parent 5c4ef08 commit fa2c18a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,17 @@ object EventValidator {
/**
* Removes all recurrence information of exceptions of (potentially recurring) events. This is:
* `RRULE`, `RDATE` and `EXDATE`.
* Note: This repair step needs to be applied after all exceptions have been found
* Note: This repair step needs to be applied after all exceptions have been found.
*
* @param exceptions exceptions of an event
*/
@VisibleForTesting
internal fun removeRecurrenceOfExceptions(exceptions: List<Event>) {
for (exception in exceptions) {
exception.rRules.clear() // Drop all RRULEs for the exception
exception.rDates.clear() // Drop all RDATEs for the exception
exception.exDates.clear() // Drop all EXDATEs for the exception
// Drop all RRULEs, RDATEs, EXDATEs for the exception
exception.rRules.clear()
exception.rDates.clear()
exception.exDates.clear()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class EventValidatorTest {
}

@Test
fun testRemoveRrulesOfRruleExceptions() {
fun testRemoveRecurrencesOfRecurringWithExceptions() {
// Test manually created event
val tz = DateUtils.ical4jTimeZone("Europe/Paris")
val manualEvent = Event().apply {
Expand Down Expand Up @@ -475,6 +475,8 @@ class EventValidatorTest {
)).first()
assertTrue(eventFromReader.rRules.size == 1)
assertTrue(eventFromReader.exceptions.first().rRules.isEmpty())
assertTrue(eventFromReader.exceptions.first().rDates.isEmpty())
assertTrue(eventFromReader.exceptions.first().exDates.isEmpty())
}

@Test
Expand Down

0 comments on commit fa2c18a

Please sign in to comment.