Commit ef62291f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '277369-typeerror-can-t-quote-activesupport-hashwithindifferentaccess' into 'master'

Properly validate milestones array in releases API PUT method

See merge request gitlab-org/gitlab!47169
parents 670cd271 97f46d5a
---
title: Fix milestones param validation for releases API PUT method
merge_request: 47169
author:
type: fixed
...@@ -91,7 +91,7 @@ module API ...@@ -91,7 +91,7 @@ module API
optional :name, type: String, desc: 'The name of the release' optional :name, type: String, desc: 'The name of the release'
optional :description, type: String, desc: 'Release notes with markdown support' 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 :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 end
put ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do put ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do
authorize_update_release! authorize_update_release!
......
...@@ -998,6 +998,17 @@ RSpec.describe API::Releases do ...@@ -998,6 +998,17 @@ RSpec.describe API::Releases do
end end
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 'multiple milestones' do
context 'with one new' do context 'with one new' do
let!(:milestone2) { create(:milestone, project: project, title: 'milestone2') } 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