• Stan Hu's avatar
    Fix snippets API not working with visibility level · 680f4377
    Stan Hu authored
    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:
    
    1. `params[:visibility]` was a string (e.g. "public")
    2. `CreateSnippetService` and `UpdateSnippetService` only looked
       at `params[:visibility_level]`, which was `nil`.
    
    To fix this, we:
    
    1. Make `CreateSnippetService` look at the newly-built
       `snippet.visibility_level`, since the right value is assigned by the
       `VisibilityLevel#visibility=` method.
    2. Modify `UpdateSnippetService` to handle both `visibility_level` and
    `visibility` parameters.
    
    Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/66050
    680f4377
sh-fix-snippet-visibility-api.yml 103 Bytes