BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0c4fa861
Commit
0c4fa861
authored
Jul 28, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Calculate build status only in build badge class
parent
9ae1ecf8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
build.rb
lib/gitlab/badge/build.rb
+13
-7
build_spec.rb
spec/lib/gitlab/badge/build_spec.rb
+13
-10
No files found.
lib/gitlab/badge/build.rb
View file @
0c4fa861
...
...
@@ -5,8 +5,16 @@ module Gitlab
#
class
Build
def
initialize
(
project
,
ref
)
@project
,
@ref
=
project
,
ref
@image
=
::
Ci
::
ImageForBuildService
.
new
.
execute
(
project
,
ref:
ref
)
@project
=
project
@ref
=
ref
end
def
status
sha
=
@project
.
commit
(
@ref
).
try
(
:sha
)
@project
.
pipelines
.
where
(
sha:
sha
,
ref:
@ref
)
.
status
||
'unknown'
end
def
metadata
...
...
@@ -18,11 +26,9 @@ module Gitlab
end
def
data
File
.
read
(
@image
[
:path
])
end
def
to_s
@image
[
:name
].
sub
(
/\.svg$/
,
''
)
File
.
read
(
Rails
.
root
.
join
(
'public/ci'
,
'build-'
+
status
+
'.svg'
)
)
end
end
end
...
...
spec/lib/gitlab/badge/build_spec.rb
View file @
0c4fa861
...
...
@@ -24,9 +24,10 @@ describe Gitlab::Badge::Build do
context
'build success'
do
before
{
build
.
success!
}
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-success'
}
describe
'#status'
do
it
'is successful'
do
expect
(
badge
.
status
).
to
eq
'success'
end
end
describe
'#data'
do
...
...
@@ -41,9 +42,10 @@ describe Gitlab::Badge::Build do
context
'build failed'
do
before
{
build
.
drop!
}
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-failed'
}
describe
'#status'
do
it
'failed'
do
expect
(
badge
.
status
).
to
eq
'failed'
end
end
describe
'#data'
do
...
...
@@ -57,9 +59,10 @@ describe Gitlab::Badge::Build do
end
context
'build does not exist'
do
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-unknown'
}
describe
'#status'
do
it
'is unknown'
do
expect
(
badge
.
status
).
to
eq
'unknown'
end
end
describe
'#data'
do
...
...
@@ -81,7 +84,7 @@ describe Gitlab::Badge::Build do
end
it
'does not take outdated pipeline into account'
do
expect
(
badge
.
to_s
).
to
eq
'build-
success'
expect
(
badge
.
status
).
to
eq
'
success'
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