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
Léo-Paul Géneau
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 @@
...
@@ -38,7 +38,7 @@
module
Ci
module
Ci
class
Build
<
CommitStatus
class
Build
<
CommitStatus
include
Gitlab
::
Application
.
routes
.
url_helpers
include
Gitlab
::
Application
.
routes
.
url_helpers
include
Build
::
Eras
e
able
include
Build
::
Erasable
LAZY_ATTRIBUTES
=
[
'trace'
]
LAZY_ATTRIBUTES
=
[
'trace'
]
...
...
app/models/ci/build/eras
e
able.rb
→
app/models/ci/build/erasable.rb
View file @
293999ca
module
Ci
module
Ci
class
Build
class
Build
module
Eras
e
able
module
Erasable
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
...
@@ -8,7 +8,7 @@ module Ci
...
@@ -8,7 +8,7 @@ module Ci
end
end
def
erase!
(
opts
=
{})
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_file!
remove_artifacts_metadata!
remove_artifacts_metadata!
...
@@ -16,16 +16,10 @@ module Ci
...
@@ -16,16 +16,10 @@ module Ci
update_erased!
(
opts
[
:erased_by
])
update_erased!
(
opts
[
:erased_by
])
end
end
def
eras
e
able?
def
erasable?
complete?
&&
(
artifacts?
||
has_trace?
)
complete?
&&
(
artifacts?
||
has_trace?
)
end
end
def
erase_url
if
eraseable?
erase_namespace_project_build_path
(
project
.
namespace
,
project
,
self
)
end
end
def
erased?
def
erased?
!
self
.
erased_at
.
nil?
!
self
.
erased_at
.
nil?
end
end
...
...
app/views/projects/builds/show.html.haml
View file @
293999ca
...
@@ -76,15 +76,15 @@
...
@@ -76,15 +76,15 @@
=
link_to
'#down-build-trace'
,
class:
'btn'
do
=
link_to
'#down-build-trace'
,
class:
'btn'
do
%i
.fa.fa-angle-down
%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
%pre
.trace
#build-trace
%code
.bash
%code
.bash
=
preserve
do
=
preserve
do
=
raw
@build
.
trace_html
=
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
%div
#down-build-trace
...
@@ -119,9 +119,10 @@
...
@@ -119,9 +119,10 @@
-
elsif
@build
.
retry_url
-
elsif
@build
.
retry_url
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
-
if
@build
.
eraseable?
-
if
@build
.
erasable?
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :delete
,
=
link_to
erase_namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
),
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
class:
'btn btn-sm btn-warning'
,
method: :delete
,
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
=
icon
(
'eraser'
)
=
icon
(
'eraser'
)
Erase
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
def
change
add_reference
:ci_builds
,
:erased_by
,
references: :users
,
index:
true
add_reference
:ci_builds
,
:erased_by
,
references: :users
,
index:
true
add_column
:ci_builds
,
:erased_at
,
:datetime
add_column
:ci_builds
,
:erased_at
,
:datetime
...
...
lib/api/builds.rb
View file @
293999ca
...
@@ -136,7 +136,7 @@ module API
...
@@ -136,7 +136,7 @@ module API
build
=
get_build
(
params
[
:build_id
])
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
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!
build
.
erase!
present
build
,
with:
Entities
::
Build
,
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'
require
'spec_helper'
describe
Ci
::
Build
::
Eras
e
able
,
models:
true
do
describe
Ci
::
Build
::
Erasable
,
models:
true
do
shared_examples
'eras
e
able'
do
shared_examples
'erasable'
do
it
'should remove artifact file'
do
it
'should remove artifact file'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
end
end
...
@@ -23,25 +23,20 @@ describe Ci::Build::Eraseable, models: true do
...
@@ -23,25 +23,20 @@ describe Ci::Build::Eraseable, models: true do
end
end
end
end
context
'build is not eras
e
able'
do
context
'build is not erasable'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
let!
(
:build
)
{
create
(
:ci_build
)
}
describe
'#erase!'
do
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
end
describe
'#eras
e
able?'
do
describe
'#erasable?'
do
subject
{
build
.
eras
e
able?
}
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
eq
false
}
it
{
is_expected
.
to
eq
false
}
end
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_falsy
}
end
end
end
context
'build is eras
e
able'
do
context
'build is erasable'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
describe
'#erase!'
do
describe
'#erase!'
do
...
@@ -50,7 +45,7 @@ describe Ci::Build::Eraseable, models: true do
...
@@ -50,7 +45,7 @@ describe Ci::Build::Eraseable, models: true do
context
'erased by user'
do
context
'erased by user'
do
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
include_examples
'eras
e
able'
include_examples
'erasable'
it
'should record user who erased a build'
do
it
'should record user who erased a build'
do
expect
(
build
.
erased_by
).
to
eq
user
expect
(
build
.
erased_by
).
to
eq
user
...
@@ -60,7 +55,7 @@ describe Ci::Build::Eraseable, models: true do
...
@@ -60,7 +55,7 @@ describe Ci::Build::Eraseable, models: true do
context
'erased by system'
do
context
'erased by system'
do
let
(
:user
)
{
nil
}
let
(
:user
)
{
nil
}
include_examples
'eras
e
able'
include_examples
'erasable'
it
'should not set user who erased a build'
do
it
'should not set user who erased a build'
do
expect
(
build
.
erased_by
).
to
be_nil
expect
(
build
.
erased_by
).
to
be_nil
...
@@ -68,16 +63,11 @@ describe Ci::Build::Eraseable, models: true do
...
@@ -68,16 +63,11 @@ describe Ci::Build::Eraseable, models: true do
end
end
end
end
describe
'#eras
e
able?'
do
describe
'#erasable?'
do
subject
{
build
.
eras
e
able?
}
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
eq
true
}
it
{
is_expected
.
to
eq
true
}
end
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_truthy
}
end
describe
'#erased?'
do
describe
'#erased?'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:success
,
:artifacts
)
}
subject
{
build
.
erased?
}
subject
{
build
.
erased?
}
...
...
spec/requests/api/builds_spec.rb
View file @
293999ca
...
@@ -175,7 +175,7 @@ describe API::API, api: true do
...
@@ -175,7 +175,7 @@ describe API::API, api: true do
delete
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/content"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/content"
,
user
)
end
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
)
}
let
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
,
project:
project
,
commit:
commit
)
}
it
'should erase build content'
do
it
'should erase build content'
do
...
@@ -186,7 +186,7 @@ describe API::API, api: true do
...
@@ -186,7 +186,7 @@ describe API::API, api: true do
end
end
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
)
}
let
(
:build
)
{
create
(
:ci_build_with_trace
,
project:
project
,
commit:
commit
)
}
it
'should respond with forbidden'
do
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