Commit 97f46d5a authored by Vladimir Shushlin's avatar Vladimir Shushlin

Properly validate milestones param in releases API

The same way we already do that for POST method
parent 290f691c
---
title: Fix milestones param validation for releases API PUT method
merge_request: 47169
author:
type: fixed
......@@ -91,7 +91,7 @@ module API
optional :name, type: String, desc: 'The name of the release'
optional :description, type: String, desc: 'Release notes with markdown support'
optional :released_at, type: DateTime, desc: 'The date when the release will be/was ready.'
optional :milestones, type: Array, desc: 'The titles of the related milestones'
optional :milestones, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The titles of the related milestones'
end
put ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do
authorize_update_release!
......
......@@ -998,6 +998,17 @@ RSpec.describe API::Releases do
end
end
context 'without milestones parameter' do
let(:params) { { name: 'some new name' } }
it 'does not change the milestone' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(returned_milestones).to match_array(['v1.0'])
end
end
context 'multiple milestones' do
context 'with one new' do
let!(:milestone2) { create(:milestone, project: project, title: 'milestone2') }
......
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