Commit a4b0530c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'vij-fix-project-snippet-param' into 'master'

Fixes visibility param in ProjectSnippet REST API

See merge request gitlab-org/gitlab!40966
parents 22e8abfe dc8927c0
---
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