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
Kazuhiko Shiozaki
gitlab-ce
Commits
293999ca
Commit
293999ca
authored
Feb 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix name of build erasable, remove superfluous method from it
parent
ec5c3c02
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
43 deletions
+28
-43
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/build/erasable.rb
app/models/ci/build/erasable.rb
+3
-9
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+9
-8
db/migrate/20160202091601_add_erasable_to_ci_build.rb
db/migrate/20160202091601_add_erasable_to_ci_build.rb
+1
-1
lib/api/builds.rb
lib/api/builds.rb
+1
-1
spec/models/ci/build/erasable_spec.rb
spec/models/ci/build/erasable_spec.rb
+11
-21
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+2
-2
No files found.
app/models/ci/build.rb
View file @
293999ca
...
...
@@ -38,7 +38,7 @@
module
Ci
class
Build
<
CommitStatus
include
Gitlab
::
Application
.
routes
.
url_helpers
include
Build
::
Eras
e
able
include
Build
::
Erasable
LAZY_ATTRIBUTES
=
[
'trace'
]
...
...
app/models/ci/build/eras
e
able.rb
→
app/models/ci/build/erasable.rb
View file @
293999ca
module
Ci
class
Build
module
Eras
e
able
module
Erasable
extend
ActiveSupport
::
Concern
included
do
...
...
@@ -8,7 +8,7 @@ module Ci
end
def
erase!
(
opts
=
{})
raise
StandardError
,
'Build not eras
eable!'
unless
erase
able?
raise
StandardError
,
'Build not eras
able!'
unless
eras
able?
remove_artifacts_file!
remove_artifacts_metadata!
...
...
@@ -16,16 +16,10 @@ module Ci
update_erased!
(
opts
[
:erased_by
])
end
def
eras
e
able?
def
erasable?
complete?
&&
(
artifacts?
||
has_trace?
)
end
def
erase_url
if
eraseable?
erase_namespace_project_build_path
(
project
.
namespace
,
project
,
self
)
end
end
def
erased?
!
self
.
erased_at
.
nil?
end
...
...
app/views/projects/builds/show.html.haml
View file @
293999ca
...
...
@@ -76,15 +76,15 @@
=
link_to
'#down-build-trace'
,
class:
'btn'
do
%i
.fa.fa-angle-down
-
unless
@build
.
erased?
-
if
@build
.
erased?
.erased.alert.alert-warning
-
erased_by
=
"by
#{
@build
.
erased_by
.
username
}
"
if
@build
.
erased_by
Build has been erased
#{
erased_by
}
#{
time_ago_with_tooltip
(
@build
.
erased_at
)
}
-
else
%pre
.trace
#build-trace
%code
.bash
=
preserve
do
=
raw
@build
.
trace_html
-
else
.erased.alert.alert-warning
-
erased_by
=
"by
#{
@build
.
erased_by
.
username
}
"
if
@build
.
erased_by
Build has been erased
#{
erased_by
}
#{
time_ago_with_tooltip
(
@build
.
erased_at
)
}
%div
#down-build-trace
...
...
@@ -119,9 +119,10 @@
-
elsif
@build
.
retry_url
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
-
if
@build
.
eraseable?
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :delete
,
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
-
if
@build
.
erasable?
=
link_to
erase_namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-sm btn-warning'
,
method: :delete
,
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
=
icon
(
'eraser'
)
Erase
...
...
db/migrate/20160202091601_add_eras
e
able_to_ci_build.rb
→
db/migrate/20160202091601_add_erasable_to_ci_build.rb
View file @
293999ca
class
AddEras
e
ableToCiBuild
<
ActiveRecord
::
Migration
class
AddErasableToCiBuild
<
ActiveRecord
::
Migration
def
change
add_reference
:ci_builds
,
:erased_by
,
references: :users
,
index:
true
add_column
:ci_builds
,
:erased_at
,
:datetime
...
...
lib/api/builds.rb
View file @
293999ca
...
...
@@ -136,7 +136,7 @@ module API
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
return
forbidden!
(
'Build is not eras
eable!'
)
unless
build
.
erase
able?
return
forbidden!
(
'Build is not eras
able!'
)
unless
build
.
eras
able?
build
.
erase!
present
build
,
with:
Entities
::
Build
,
...
...
spec/models/ci/build/eras
e
able_spec.rb
→
spec/models/ci/build/erasable_spec.rb
View file @
293999ca
require
'spec_helper'
describe
Ci
::
Build
::
Eras
e
able
,
models:
true
do
shared_examples
'eras
e
able'
do
describe
Ci
::
Build
::
Erasable
,
models:
true
do
shared_examples
'erasable'
do
it
'should remove artifact file'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
end
...
...
@@ -23,25 +23,20 @@ describe Ci::Build::Eraseable, models: true do
end
end
context
'build is not eras
e
able'
do
context
'build is not erasable'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
describe
'#erase!'
do
it
{
expect
{
build
.
erase!
}.
to
raise_error
(
StandardError
,
/Build not eras
e
able!/
)}
it
{
expect
{
build
.
erase!
}.
to
raise_error
(
StandardError
,
/Build not erasable!/
)}
end
describe
'#eras
e
able?'
do
subject
{
build
.
eras
e
able?
}
describe
'#erasable?'
do
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
eq
false
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'build is eras
e
able'
do
context
'build is erasable'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
describe
'#erase!'
do
...
...
@@ -50,7 +45,7 @@ describe Ci::Build::Eraseable, models: true do
context
'erased by user'
do
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
include_examples
'eras
e
able'
include_examples
'erasable'
it
'should record user who erased a build'
do
expect
(
build
.
erased_by
).
to
eq
user
...
...
@@ -60,7 +55,7 @@ describe Ci::Build::Eraseable, models: true do
context
'erased by system'
do
let
(
:user
)
{
nil
}
include_examples
'eras
e
able'
include_examples
'erasable'
it
'should not set user who erased a build'
do
expect
(
build
.
erased_by
).
to
be_nil
...
...
@@ -68,16 +63,11 @@ describe Ci::Build::Eraseable, models: true do
end
end
describe
'#eras
e
able?'
do
subject
{
build
.
eras
e
able?
}
describe
'#erasable?'
do
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
eq
true
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_truthy
}
end
describe
'#erased?'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
subject
{
build
.
erased?
}
...
...
spec/requests/api/builds_spec.rb
View file @
293999ca
...
...
@@ -175,7 +175,7 @@ describe API::API, api: true do
delete
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/content"
,
user
)
end
context
'build is eras
e
able'
do
context
'build is erasable'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
,
project:
project
,
commit:
commit
)
}
it
'should erase build content'
do
...
...
@@ -186,7 +186,7 @@ describe API::API, api: true do
end
end
context
'build is not eras
e
able'
do
context
'build is not erasable'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
project:
project
,
commit:
commit
)
}
it
'should respond with forbidden'
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