fix(calendar): persist settings on PUT/POST
Accept calendar.settings (e.g. week_patterns) in validate_update and convert_field; apply on create like tags. Unblocks Front#42 pattern save which previously got 200 with empty settings.
This commit is contained in:
@@ -23,6 +23,7 @@ test() ->
|
||||
test_get_calendar_unauthorized(CalId),
|
||||
test_get_calendar_not_found(Token),
|
||||
test_update_calendar(Token, CalId),
|
||||
test_update_calendar_settings(Token, CalId),
|
||||
test_update_calendar_forbidden(OtherToken, CalId),
|
||||
test_delete_calendar(Token, CalId),
|
||||
test_delete_calendar_forbidden(OtherToken, CalId),
|
||||
@@ -60,6 +61,26 @@ test_update_calendar(Token, CalId) ->
|
||||
?assertEqual(<<"New desc">>, maps:get(<<"description">>, Updated)),
|
||||
ct:pal(" OK").
|
||||
|
||||
test_update_calendar_settings(Token, CalId) ->
|
||||
ct:pal(" TEST: Persist calendar.settings.week_patterns"),
|
||||
Path = <<"/v1/calendars/", CalId/binary>>,
|
||||
Settings = #{
|
||||
<<"week_patterns">> => [
|
||||
#{
|
||||
<<"id">> => <<"pat1">>,
|
||||
<<"name">> => <<"Mon-Fri">>,
|
||||
<<"slots">> => [
|
||||
#{<<"weekday">> => 1, <<"time">> => <<"10:00">>, <<"duration">> => 60, <<"title">> => <<"Open">>}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
Updated = api_test_runner:client_put(Path, Token, #{settings => Settings}),
|
||||
?assertEqual(Settings, maps:get(<<"settings">>, Updated)),
|
||||
Got = api_test_runner:client_get(Path, Token),
|
||||
?assertEqual(Settings, maps:get(<<"settings">>, Got)),
|
||||
ct:pal(" OK").
|
||||
|
||||
test_update_calendar_forbidden(OtherToken, CalId) ->
|
||||
ct:pal(" TEST: Update calendar by non-owner (403)"),
|
||||
Path = <<"/v1/calendars/", CalId/binary>>,
|
||||
|
||||
Reference in New Issue
Block a user