Commit 0b6c4ef7 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'nfriend-make-release-title-submit-null' into 'master'

Update New Release page to send title as `null` when empty

See merge request gitlab-org/gitlab!38990
parents 90c70427 6ba8e952
...@@ -10,13 +10,15 @@ import { ...@@ -10,13 +10,15 @@ import {
* @param {string} createFrom The ref to create a new tag from, if necessary * @param {string} createFrom The ref to create a new tag from, if necessary
*/ */
export const releaseToApiJson = (release, createFrom = null) => { export const releaseToApiJson = (release, createFrom = null) => {
const name = release.name?.trim().length > 0 ? release.name.trim() : null;
const milestones = release.milestones ? release.milestones.map(milestone => milestone.title) : []; const milestones = release.milestones ? release.milestones.map(milestone => milestone.title) : [];
return convertObjectPropsToSnakeCase( return convertObjectPropsToSnakeCase(
{ {
name,
tagName: release.tagName, tagName: release.tagName,
ref: createFrom, ref: createFrom,
name: release.name,
description: release.description, description: release.description,
milestones, milestones,
assets: release.assets, assets: release.assets,
......
...@@ -41,6 +41,24 @@ describe('releases/util.js', () => { ...@@ -41,6 +41,24 @@ describe('releases/util.js', () => {
}); });
}); });
describe('release.name', () => {
it.each`
input | output
${null} | ${null}
${''} | ${null}
${' \t\n\r\n'} | ${null}
${' Release name '} | ${'Release name'}
`('converts a name like `$input` to `$output`', ({ input, output }) => {
const release = { name: input };
const expectedJson = {
name: output,
};
expect(releaseToApiJson(release)).toMatchObject(expectedJson);
});
});
describe('when release.milestones is falsy', () => { describe('when release.milestones is falsy', () => {
it('includes a "milestone" property in the returned result as an empty array', () => { it('includes a "milestone" property in the returned result as an empty array', () => {
const release = {}; const release = {};
......
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