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
01906796
Commit
01906796
authored
Sep 21, 2021
by
Hugo Ortiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent push_package event if Maven package file creation fails
parent
11942424
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
lib/api/maven_packages.rb
lib/api/maven_packages.rb
+1
-2
spec/requests/api/maven_packages_spec.rb
spec/requests/api/maven_packages_spec.rb
+13
-11
No files found.
lib/api/maven_packages.rb
View file @
01906796
...
...
@@ -264,8 +264,6 @@ module API
when
'md5'
''
else
track_package_event
(
'push_package'
,
:maven
,
user:
current_user
,
project:
user_project
,
namespace:
user_project
.
namespace
)
if
jar_file?
(
format
)
file_params
=
{
file:
params
[
:file
],
size:
params
[
'file.size'
],
...
...
@@ -276,6 +274,7 @@ module API
}
::
Packages
::
CreatePackageFileService
.
new
(
package
,
file_params
.
merge
(
build:
current_authenticated_job
)).
execute
track_package_event
(
'push_package'
,
:maven
,
user:
current_user
,
project:
user_project
,
namespace:
user_project
.
namespace
)
if
jar_file?
(
format
)
end
end
end
...
...
spec/requests/api/maven_packages_spec.rb
View file @
01906796
...
...
@@ -798,8 +798,6 @@ RSpec.describe API::MavenPackages do
end
describe
'PUT /api/v4/projects/:id/packages/maven/*path/:file_name'
do
include_context
'workhorse headers'
let
(
:send_rewritten_field
)
{
true
}
let
(
:file_upload
)
{
fixture_file_upload
(
'spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.jar'
)
}
...
...
@@ -833,6 +831,8 @@ RSpec.describe API::MavenPackages do
context
'when params from workhorse are correct'
do
let
(
:params
)
{
{
file:
file_upload
}
}
subject
{
upload_file_with_token
(
params:
params
)
}
context
'file size is too large'
do
it
'rejects the request'
do
allow_next_instance_of
(
UploadedFile
)
do
|
uploaded_file
|
...
...
@@ -851,18 +851,20 @@ RSpec.describe API::MavenPackages do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
context
'without workhorse header'
do
let
(
:workhorse_headers
)
{
{}
}
subject
{
upload_file_with_token
(
params:
params
)
}
it_behaves_like
'package workhorse uploads'
end
context
'event tracking'
do
subject
{
upload_file_with_token
(
params:
params
)
}
it_behaves_like
'a package tracking event'
,
described_class
.
name
,
'push_package'
context
'when the package file fails to be created'
do
before
do
allow_next_instance_of
(
::
Packages
::
CreatePackageFileService
)
do
|
create_package_file_service
|
allow
(
create_package_file_service
).
to
receive
(
:execute
).
and_raise
(
StandardError
)
end
end
it_behaves_like
'not a package tracking event'
end
end
it
'creates package and stores package file'
do
...
...
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