Fix snippets API not working with visibility level
When a restricted visibility level of private
is set in the instance,
creating a snippet with the visibility
level would always fail.
This happened because:
-
params[:visibility]
was a string (e.g. "public") -
CreateSnippetService
andUpdateSnippetService
only looked atparams[:visibility_level]
, which wasnil
.
To fix this, we:
- Make
CreateSnippetService
look at the newly-builtsnippet.visibility_level
, since the right value is assigned by theVisibilityLevel#visibility=
method. - Modify
UpdateSnippetService
to handle bothvisibility_level
andvisibility
parameters.
Edited by Stan Hu