Implement commercial calendars: booking_open, specialists, expire without type downgrade.
Refs EventHub/EventHubBack#54
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("records.hrl").
|
||||
|
||||
-define(TABLES, [user, calendar, event, booking, admin]).
|
||||
-define(TABLES, [user, calendar, event, booking, admin, subscription]).
|
||||
|
||||
setup() ->
|
||||
eh_test_support:start_mnesia(),
|
||||
@@ -19,7 +19,7 @@ booking_integration_test_() ->
|
||||
fun setup/0,
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Booking create stays pending", fun test_pending_booking_flow/0},
|
||||
{"Booking auto confirms", fun test_auto_booking_flow/0},
|
||||
{"Full booking flow with manual confirmation", fun test_manual_booking_flow/0},
|
||||
{"Capacity management test", fun test_capacity_management/0},
|
||||
{"Multiple bookings test", fun test_multiple_bookings/0}
|
||||
@@ -39,24 +39,25 @@ create_user() ->
|
||||
mnesia:dirty_write(User),
|
||||
UserId.
|
||||
|
||||
create_commercial(OwnerId, Confirmation) ->
|
||||
{ok, _} = core_subscription:create(OwnerId, monthly, true),
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Cal">>, <<"">>, Confirmation, commercial),
|
||||
Calendar.
|
||||
|
||||
add_days(DateTime, Days) ->
|
||||
Sec = calendar:datetime_to_gregorian_seconds(DateTime) + Days * 86400,
|
||||
calendar:gregorian_seconds_to_datetime(Sec).
|
||||
|
||||
test_pending_booking_flow() ->
|
||||
test_auto_booking_flow() ->
|
||||
OwnerId = create_user(),
|
||||
ParticipantId = create_user(),
|
||||
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Auto">>, <<"">>, auto),
|
||||
Calendar = create_commercial(OwnerId, auto),
|
||||
|
||||
StartTime = eh_test_support:future_start(),
|
||||
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
|
||||
|
||||
{ok, Booking} = logic_booking:create_booking(ParticipantId, Event#event.id),
|
||||
?assertEqual(pending, Booking#booking.status),
|
||||
|
||||
{ok, Stored} = core_booking:get_by_id(Booking#booking.id),
|
||||
?assertEqual(pending, Stored#booking.status),
|
||||
?assertEqual(confirmed, Booking#booking.status),
|
||||
|
||||
{ok, EventBookings} = logic_booking:list_event_bookings(Event#event.id),
|
||||
?assertEqual(1, length(EventBookings)),
|
||||
@@ -67,8 +68,7 @@ test_pending_booking_flow() ->
|
||||
test_manual_booking_flow() ->
|
||||
OwnerId = create_user(),
|
||||
ParticipantId = create_user(),
|
||||
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Manual">>, <<"">>, manual),
|
||||
Calendar = create_commercial(OwnerId, manual),
|
||||
|
||||
StartTime = eh_test_support:future_start(),
|
||||
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
|
||||
@@ -88,7 +88,7 @@ test_capacity_management() ->
|
||||
Participant2Id = create_user(),
|
||||
Participant3Id = create_user(),
|
||||
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"">>, manual),
|
||||
Calendar = create_commercial(OwnerId, manual),
|
||||
|
||||
StartTime = eh_test_support:future_start(),
|
||||
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
|
||||
@@ -108,8 +108,7 @@ test_capacity_management() ->
|
||||
test_multiple_bookings() ->
|
||||
OwnerId = create_user(),
|
||||
ParticipantId = create_user(),
|
||||
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"">>, manual),
|
||||
Calendar = create_commercial(OwnerId, manual),
|
||||
|
||||
Base = eh_test_support:future_start(),
|
||||
StartTime1 = Base,
|
||||
|
||||
Reference in New Issue
Block a user