fix(api): resolve public calendar GET by unique short_name.
CI / test (push) Successful in 7m28s
CI / deploy-ift (push) Successful in 2m46s
CI / e2e-ift (push) Successful in 1m26s
CI / deploy-stage (push) Successful in 2m4s
CI / e2e-stage (push) Successful in 2m4s

This commit is contained in:
2026-08-14 15:00:41 +03:00
parent 658cbda4fe
commit 3d7ae0d372
8 changed files with 67 additions and 18 deletions
+14
View File
@@ -12,6 +12,7 @@ setup() ->
{attributes, record_info(fields, calendar)},
{ram_copies, [node()]}
]),
{atomic, ok} = mnesia:add_table_index(calendar, short_name),
mnesia:create_table(subscription, [
{attributes, record_info(fields, subscription)},
{ram_copies, [node()]}
@@ -38,6 +39,7 @@ logic_calendar_test_() ->
{"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},
{"Get calendar by short_name", fun test_get_calendar_by_short_name/0},
{"List calendars test", fun test_list_calendars/0},
{"Update calendar test", fun test_update_calendar/0},
{"Persist calendar settings (week_patterns)", fun test_update_settings/0},
@@ -104,6 +106,18 @@ test_get_calendar() ->
?assertMatch({error, access_denied},
logic_calendar:get_calendar(OtherUserId, Calendar#calendar.id)).
test_get_calendar_by_short_name() ->
UserId = create_test_user(),
{ok, _} = logic_subscription:start_trial(UserId),
{ok, Cal} = logic_calendar:create_calendar(UserId, <<"Studio">>, <<>>, manual, commercial),
Slug = <<"bizcal-unit-", (Cal#calendar.id)/binary>>,
{ok, _} = core_calendar:update(Cal#calendar.id, [{short_name, Slug}]),
{ok, Found} = logic_calendar:get_calendar(<<>>, Slug),
?assertEqual(Cal#calendar.id, Found#calendar.id),
{ok, Found2} = logic_calendar:get_calendar(UserId, Slug),
?assertEqual(Cal#calendar.id, Found2#calendar.id),
?assertEqual({error, not_found}, logic_calendar:get_calendar(<<>>, <<"no-such-slug">>)).
test_list_calendars() ->
UserId = create_test_user(),
{ok, _} = logic_calendar:create_calendar(UserId, <<"Calendar 1">>, <<"">>, manual),