Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e29703ab
Commit
e29703ab
authored
Jul 20, 2020
by
Nathan Friend
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add createRelease endpoint wrapper to api.js
And also add some missing tests.
parent
c74d9985
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
0 deletions
+97
-0
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+6
-0
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+91
-0
No files found.
app/assets/javascripts/api.js
View file @
e29703ab
...
...
@@ -530,6 +530,12 @@ const Api = {
return
axios
.
get
(
url
);
},
createRelease
(
projectPath
,
release
)
{
const
url
=
Api
.
buildUrl
(
this
.
releasesPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
projectPath
));
return
axios
.
post
(
url
,
release
);
},
updateRelease
(
projectPath
,
tagName
,
release
)
{
const
url
=
Api
.
buildUrl
(
this
.
releasePath
)
.
replace
(
'
:id
'
,
encodeURIComponent
(
projectPath
))
...
...
spec/frontend/api_spec.js
View file @
e29703ab
...
...
@@ -666,6 +666,97 @@ describe('Api', () => {
});
});
describe
(
'
release
'
,
()
=>
{
const
dummyProjectPath
=
'
gitlab-org/gitlab
'
;
const
dummyTagName
=
'
v1.3
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
encodeURIComponent
(
dummyProjectPath
,
)}
/releases/
${
encodeURIComponent
(
dummyTagName
)}
`
;
describe
(
'
when the release is successfully returned
'
,
()
=>
{
it
(
'
resolves the Promise
'
,
()
=>
{
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
);
return
Api
.
release
(
dummyProjectPath
,
dummyTagName
).
then
(()
=>
{
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
});
});
});
describe
(
'
when an error occurs while fetching the release
'
,
()
=>
{
it
(
'
rejects the Promise
'
,
()
=>
{
mock
.
onGet
(
expectedUrl
).
replyOnce
(
500
);
return
Api
.
release
(
dummyProjectPath
,
dummyTagName
).
catch
(()
=>
{
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
createRelease
'
,
()
=>
{
const
dummyProjectPath
=
'
gitlab-org/gitlab
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
encodeURIComponent
(
dummyProjectPath
,
)}
/releases`
;
const
release
=
{
name
:
'
Version 1.0
'
,
};
describe
(
'
when the release is successfully created
'
,
()
=>
{
it
(
'
resolves the Promise
'
,
()
=>
{
mock
.
onPost
(
expectedUrl
,
release
).
replyOnce
(
201
);
return
Api
.
createRelease
(
dummyProjectPath
,
release
).
then
(()
=>
{
expect
(
mock
.
history
.
post
).
toHaveLength
(
1
);
});
});
});
describe
(
'
when an error occurs while creating the release
'
,
()
=>
{
it
(
'
rejects the Promise
'
,
()
=>
{
mock
.
onPost
(
expectedUrl
,
release
).
replyOnce
(
500
);
return
Api
.
createRelease
(
dummyProjectPath
,
release
).
catch
(()
=>
{
expect
(
mock
.
history
.
post
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
updateRelease
'
,
()
=>
{
const
dummyProjectPath
=
'
gitlab-org/gitlab
'
;
const
dummyTagName
=
'
v1.3
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
encodeURIComponent
(
dummyProjectPath
,
)}
/releases/
${
encodeURIComponent
(
dummyTagName
)}
`
;
const
release
=
{
name
:
'
Version 1.0
'
,
};
describe
(
'
when the release is successfully created
'
,
()
=>
{
it
(
'
resolves the Promise
'
,
()
=>
{
mock
.
onPut
(
expectedUrl
,
release
).
replyOnce
(
200
);
return
Api
.
updateRelease
(
dummyProjectPath
,
dummyTagName
,
release
).
then
(()
=>
{
expect
(
mock
.
history
.
put
).
toHaveLength
(
1
);
});
});
});
describe
(
'
when an error occurs while creating the release
'
,
()
=>
{
it
(
'
rejects the Promise
'
,
()
=>
{
mock
.
onPut
(
expectedUrl
,
release
).
replyOnce
(
500
);
return
Api
.
updateRelease
(
dummyProjectPath
,
dummyTagName
,
release
).
catch
(()
=>
{
expect
(
mock
.
history
.
put
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
createReleaseLink
'
,
()
=>
{
const
dummyProjectPath
=
'
gitlab-org/gitlab
'
;
const
dummyReleaseTag
=
'
v1.3
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment