From 9c8afe411721fcb7faa4f2d669c2cd7b289f1f00 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 24 Sep 2026 16:19:20 +0200 Subject: feat: an event is editable only when the user organises it --- tests/test_calendarstore.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/test_calendarstore.cpp') 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{ 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" -- cgit v1.2.3