diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-24 16:19:20 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-24 16:19:20 +0200 |
| commit | 9c8afe411721fcb7faa4f2d669c2cd7b289f1f00 (patch) | |
| tree | bbfefcbf2b3f0bcdfdcddc9574b75d2901256e72 /tests/test_calendarstore.cpp | |
| parent | 5c6a11e72755cc500c77b5fa92dae43ab990f21e (diff) | |
| download | qtmaildir-9c8afe411721fcb7faa4f2d669c2cd7b289f1f00.tar.gz qtmaildir-9c8afe411721fcb7faa4f2d669c2cd7b289f1f00.zip | |
feat: an event is editable only when the user organises it
Diffstat (limited to 'tests/test_calendarstore.cpp')
| -rw-r--r-- | tests/test_calendarstore.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_calendarstore.cpp b/tests/test_calendarstore.cpp index b27c6ec..1df8447 100644 --- a/tests/test_calendarstore.cpp +++ b/tests/test_calendarstore.cpp @@ -103,6 +103,7 @@ private slots: void readsTheRepeatRuleExdatesAndOverrides(); void expandsADenseOldSeriesToTheWindow(); void anAllDayOverrideKeepsItsOwnAllDayFlag(); + void editableOnlyWhenTheUserOrganisesIt(); }; void TestCalendarStore::parsesAUtcEvent() @@ -365,5 +366,36 @@ void TestCalendarStore::readsTheRepeatRuleExdatesAndOverrides() QCOMPARE(e.exdates, QList<QDateTime>{ utc(2026, 10, 30, 8) }); } +void TestCalendarStore::editableOnlyWhenTheUserOrganisesIt() +{ + const QStringList own = { QStringLiteral("me@example.org"), QStringLiteral("alt@example.org") }; + CalCollection writable; + writable.dir = QStringLiteral("x"); + CalCollection readOnly = writable; + readOnly.readOnly = true; + + const CalEvent mine = parse(vevent(QStringLiteral( + "UID:1@example.org\r\nDTSTART:20260922T080000Z\r\n" + "ORGANIZER;CN=Me:mailto:ME@Example.org\r\n" + "ATTENDEE;CN=Other;PARTSTAT=ACCEPTED:mailto:other@example.org\r\n"))); + const CalEvent theirs = parse(vevent(QStringLiteral( + "UID:2@example.org\r\nDTSTART:20260922T080000Z\r\n" + "ORGANIZER;CN=Other:mailto:other@example.org\r\n" + "ATTENDEE:mailto:me@example.org\r\n"))); + const CalEvent nobodys = parse(vevent(QStringLiteral( + "UID:3@example.org\r\nDTSTART:20260922T080000Z\r\n"))); + + // Case-insensitive, and "mailto:" is not part of the address. + QVERIFY(CalendarStore::isEditable(mine, writable, own)); + QVERIFY(!CalendarStore::isEditable(theirs, writable, own)); + QVERIFY(CalendarStore::isEditable(nobodys, writable, own)); + QVERIFY(!CalendarStore::isEditable(nobodys, readOnly, own)); + + QCOMPARE(mine.organizer.name, QStringLiteral("Me")); + QCOMPARE(mine.attendees.size(), 1); + QCOMPARE(mine.attendees[0].partstat, QStringLiteral("ACCEPTED")); + QCOMPARE(mine.attendees[0].address, QStringLiteral("other@example.org")); +} + QTEST_MAIN(TestCalendarStore) #include "test_calendarstore.moc" |
