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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
9d8dca08
Commit
9d8dca08
authored
Jun 29, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AR callbacks as suggested by:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4964#note_12744656
parent
1bc0d732
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
app/models/ci/build.rb
app/models/ci/build.rb
+5
-1
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+0
-1
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+6
-2
No files found.
app/models/ci/build.rb
View file @
9d8dca08
...
@@ -19,6 +19,7 @@ module Ci
...
@@ -19,6 +19,7 @@ module Ci
acts_as_taggable
acts_as_taggable
before_save
:update_artifacts_size
,
if: :artifacts_file_changed?
before_destroy
{
project
}
before_destroy
{
project
}
after_create
:execute_hooks
after_create
:execute_hooks
...
@@ -340,7 +341,6 @@ module Ci
...
@@ -340,7 +341,6 @@ module Ci
def
erase_artifacts!
def
erase_artifacts!
remove_artifacts_file!
remove_artifacts_file!
remove_artifacts_metadata!
remove_artifacts_metadata!
self
.
artifacts_size
=
nil
save
save
end
end
...
@@ -381,6 +381,10 @@ module Ci
...
@@ -381,6 +381,10 @@ module Ci
private
private
def
update_artifacts_size
self
.
artifacts_size
=
artifacts_file
.
size
end
def
erase_trace!
def
erase_trace!
self
.
trace
=
nil
self
.
trace
=
nil
end
end
...
...
lib/ci/api/builds.rb
View file @
9d8dca08
...
@@ -147,7 +147,6 @@ module Ci
...
@@ -147,7 +147,6 @@ module Ci
build
.
artifacts_file
=
artifacts
build
.
artifacts_file
=
artifacts
build
.
artifacts_metadata
=
metadata
build
.
artifacts_metadata
=
metadata
build
.
artifacts_expire_in
=
params
[
'expire_in'
]
build
.
artifacts_expire_in
=
params
[
'expire_in'
]
build
.
artifacts_size
=
artifacts
.
size
if
build
.
save
if
build
.
save
present
(
build
,
with:
Entities
::
BuildDetails
)
present
(
build
,
with:
Entities
::
BuildDetails
)
...
...
spec/requests/ci/api/builds_spec.rb
View file @
9d8dca08
...
@@ -476,13 +476,17 @@ describe Ci::API::API do
...
@@ -476,13 +476,17 @@ describe Ci::API::API do
describe
'DELETE /builds/:id/artifacts'
do
describe
'DELETE /builds/:id/artifacts'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
before
{
delete
delete_url
,
token:
build
.
token
}
before
do
delete
delete_url
,
token:
build
.
token
build
.
reload
end
it
'should remove build artifacts'
do
it
'should remove build artifacts'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_size
).
to
be_falsy
expect
(
build
.
artifacts_size
).
to
eq
(
0
)
end
end
end
end
...
...
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