fix: gate calendar reviews on confirmed booking. Refs EventHub/EventHubFront#8

This commit is contained in:
2026-07-20 21:08:12 +03:00
parent dcb5163946
commit 4932f9abae
3 changed files with 32 additions and 1 deletions
Regular → Executable
+11
View File
@@ -21,6 +21,7 @@ logic_review_test_() ->
[
{"Create review for event", fun test_create_event_review/0},
{"Create review for calendar", fun test_create_calendar_review/0},
{"Cannot review calendar without booking", fun test_cannot_review_calendar_without_booking/0},
{"Cannot review without booking", fun test_cannot_review_without_booking/0},
{"Cannot review twice", fun test_cannot_review_twice/0},
{"Update own review", fun test_update_own_review/0},
@@ -74,10 +75,20 @@ test_create_calendar_review() ->
OwnerId = create_test_user(),
ReviewerId = create_test_user(),
CalendarId = create_test_calendar(OwnerId),
EventId = create_test_event(CalendarId),
create_booking(ReviewerId, EventId),
{ok, Review} = logic_review:create_review(ReviewerId, calendar, CalendarId, 4, <<"Nice">>),
?assertEqual(4, Review#review.rating).
test_cannot_review_calendar_without_booking() ->
OwnerId = create_test_user(),
UserId = create_test_user(),
CalendarId = create_test_calendar(OwnerId),
_EventId = create_test_event(CalendarId),
{error, cannot_review} = logic_review:create_review(UserId, calendar, CalendarId, 4, <<"Nope">>).
test_cannot_review_without_booking() ->
OwnerId = create_test_user(),
UserId = create_test_user(),