fix: persist specialist_id on event create; 402 commercial without active sub. Fixes EventHub/EventHubBack#61
This commit is contained in:
@@ -31,6 +31,7 @@ logic_calendar_test_() ->
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Create calendar test", fun test_create_calendar/0},
|
||||
{"Create commercial requires subscription", fun test_create_commercial_gate/0},
|
||||
{"Get calendar test", fun test_get_calendar/0},
|
||||
{"List calendars test", fun test_list_calendars/0},
|
||||
{"Update calendar test", fun test_update_calendar/0},
|
||||
@@ -66,6 +67,18 @@ test_create_calendar() ->
|
||||
?assertEqual(personal, Calendar#calendar.type),
|
||||
?assertEqual(Confirmation, Calendar#calendar.confirmation).
|
||||
|
||||
test_create_commercial_gate() ->
|
||||
UserId = create_test_user(),
|
||||
?assertMatch({error, subscription_required},
|
||||
logic_calendar:create_calendar(UserId, <<"Studio">>, <<>>, manual, commercial)),
|
||||
{ok, Personal} = logic_calendar:create_calendar(UserId, <<"Personal">>, <<>>, manual, personal),
|
||||
?assertEqual(personal, Personal#calendar.type),
|
||||
?assertMatch({error, subscription_required},
|
||||
logic_calendar:update_calendar(UserId, Personal#calendar.id, [{type, commercial}])),
|
||||
{ok, _} = logic_subscription:start_trial(UserId),
|
||||
{ok, Commercial} = logic_calendar:create_calendar(UserId, <<"Studio">>, <<>>, manual, commercial),
|
||||
?assertEqual(commercial, Commercial#calendar.type).
|
||||
|
||||
test_get_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test">>, <<"">>, manual),
|
||||
@@ -92,6 +105,7 @@ test_list_calendars() ->
|
||||
test_update_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Original">>, <<"">>, manual),
|
||||
{ok, _} = logic_subscription:start_trial(UserId),
|
||||
|
||||
Updates = [{title, <<"Updated">>}, {type, commercial}, {confirmation, auto}],
|
||||
{ok, Updated} = logic_calendar:update_calendar(UserId, Calendar#calendar.id, Updates),
|
||||
@@ -122,6 +136,7 @@ test_access_control() ->
|
||||
?assertNot(logic_calendar:can_edit(OtherId, PersonalCalendar)),
|
||||
?assertNot(logic_calendar:can_access(OtherId, PersonalCalendar)),
|
||||
|
||||
{ok, _} = logic_subscription:start_trial(OwnerId),
|
||||
{ok, CommercialCalendar} = logic_calendar:update_calendar(OwnerId, PersonalCalendar#calendar.id, [{type, commercial}]),
|
||||
?assert(logic_calendar:can_access(OtherId, CommercialCalendar)),
|
||||
?assertNot(logic_calendar:can_edit(OtherId, CommercialCalendar)),
|
||||
|
||||
Reference in New Issue
Block a user