Commit dc8927c0 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Fixes visibility param in ProjectSnippet REST API

This renames a param requirement in the ProjectSnippet
REST API update endpoint which was incorrectly
set to visibility_level
parent 9823cc80
---
title: Fix visibility param for ProjectSnippet REST endpoint
merge_request: 40966
author:
type: fixed
......@@ -95,7 +95,7 @@ module API
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
desc: 'The visibility of the snippet'
at_least_one_of :title, :file_name, :content, :visibility_level
at_least_one_of :title, :file_name, :content, :visibility
end
# rubocop: disable CodeReuse/ActiveRecord
put ":id/snippets/:snippet_id" do
......
......@@ -329,6 +329,13 @@ RSpec.describe API::ProjectSnippets do
expect(snippet.description).to eq(new_description)
end
it 'updates snippet with visibility parameter' do
expect { update_snippet(params: { visibility: 'private' }) }
.to change { snippet.reload.visibility }
expect(snippet.visibility).to eq('private')
end
it 'returns 404 for invalid snippet id' do
update_snippet(snippet_id: non_existing_record_id, params: { title: 'foo' })
......@@ -340,6 +347,7 @@ RSpec.describe API::ProjectSnippets do
update_snippet
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq 'title, file_name, content, visibility are missing, at least one parameter must be provided'
end
it 'returns 400 if content is blank' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment