Commit 2a27685e authored by Hugo Ortiz's avatar Hugo Ortiz

Prevent push_package event if Composer package creation fails

parent a0ded336
...@@ -137,12 +137,12 @@ module API ...@@ -137,12 +137,12 @@ module API
bad_request! bad_request!
end end
track_package_event('push_package', :composer, project: authorized_user_project, user: current_user, namespace: authorized_user_project.namespace)
::Packages::Composer::CreatePackageService ::Packages::Composer::CreatePackageService
.new(authorized_user_project, current_user, declared_params.merge(build: current_authenticated_job)) .new(authorized_user_project, current_user, declared_params.merge(build: current_authenticated_job))
.execute .execute
track_package_event('push_package', :composer, project: authorized_user_project, user: current_user, namespace: authorized_user_project.namespace)
created! created!
end end
......
...@@ -85,7 +85,18 @@ RSpec.shared_examples 'Composer package creation' do |user_type, status, add_mem ...@@ -85,7 +85,18 @@ RSpec.shared_examples 'Composer package creation' do |user_type, status, add_mem
expect(response).to have_gitlab_http_status(status) expect(response).to have_gitlab_http_status(status)
end end
it_behaves_like 'a package tracking event', described_class.name, 'push_package' 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
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