Commit e0f3eb8c authored by Josianne Hyson's avatar Josianne Hyson

Ensure existing group exports are removed in API

Call the same service in the group export API as the controller for the
frontend. This keeps the consistency with the UI functionality.

Relates to: https://gitlab.com/gitlab-org/gitlab/-/issues/211805
parent c3ddff7f
......@@ -27,9 +27,13 @@ module API
detail 'This feature was introduced in GitLab 12.5.'
end
post ':id/export' do
GroupExportWorker.perform_async(current_user.id, user_group.id, params) # rubocop:disable CodeReuse/Worker
export_service = ::Groups::ImportExport::ExportService.new(group: user_group, user: current_user)
if export_service.async_execute
accepted!
else
render_api_error!(message: 'Group export could not be started.')
end
end
end
end
......
......@@ -102,6 +102,19 @@ describe API::GroupExport do
end
end
context 'when the export cannot be started' do
before do
group.add_owner(user)
allow(GroupExportWorker).to receive(:perform_async).and_return(nil)
end
it 'returns an error' do
post api(path, user)
expect(response).to have_gitlab_http_status(:error)
end
end
context 'when user is not a group owner' do
before do
group.add_developer(user)
......
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