Commit 1f580981 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Merge branch '330475-prevent-push_package-event-if-composer-package-creation-fails' into 'master'

Prevent push_package event if Composer package creation fails

See merge request gitlab-org/gitlab!72192
parents 9573d754 2a27685e
......@@ -137,12 +137,12 @@ module API
bad_request!
end
track_package_event('push_package', :composer, project: authorized_user_project, user: current_user, namespace: authorized_user_project.namespace)
::Packages::Composer::CreatePackageService
.new(authorized_user_project, current_user, declared_params.merge(build: current_authenticated_job))
.execute
track_package_event('push_package', :composer, project: authorized_user_project, user: current_user, namespace: authorized_user_project.namespace)
created!
end
......
......@@ -85,7 +85,18 @@ RSpec.shared_examples 'Composer package creation' do |user_type, status, add_mem
expect(response).to have_gitlab_http_status(status)
end
it_behaves_like 'a package tracking event', described_class.name, 'push_package'
context 'when package creation fails' do
before do
allow_next_instance_of(::Packages::Composer::CreatePackageService) do |create_package_service|
allow(create_package_service).to receive(:execute).and_raise(StandardError)
end
end
it_behaves_like 'not a package tracking event'
end
end
end
......
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