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
9f0b46c0
Commit
9f0b46c0
authored
Aug 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move badges to separate modules and add base class
parent
6f0b5800
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
82 additions
and
55 deletions
+82
-55
app/controllers/projects/badges_controller.rb
app/controllers/projects/badges_controller.rb
+1
-1
app/controllers/projects/pipelines_settings_controller.rb
app/controllers/projects/pipelines_settings_controller.rb
+1
-1
lib/gitlab/badge/base.rb
lib/gitlab/badge/base.rb
+21
-0
lib/gitlab/badge/build.rb
lib/gitlab/badge/build.rb
+0
-30
lib/gitlab/badge/build/metadata.rb
lib/gitlab/badge/build/metadata.rb
+1
-1
lib/gitlab/badge/build/status.rb
lib/gitlab/badge/build/status.rb
+32
-0
lib/gitlab/badge/build/template.rb
lib/gitlab/badge/build/template.rb
+1
-1
lib/gitlab/badge/coverage.rb
lib/gitlab/badge/coverage.rb
+0
-17
lib/gitlab/badge/coverage/report.rb
lib/gitlab/badge/coverage/report.rb
+19
-0
spec/lib/gitlab/badge/build/status_spec.rb
spec/lib/gitlab/badge/build/status_spec.rb
+1
-1
spec/lib/gitlab/badge/coverage/report_spec.rb
spec/lib/gitlab/badge/coverage/report_spec.rb
+5
-3
No files found.
app/controllers/projects/badges_controller.rb
View file @
9f0b46c0
...
@@ -4,7 +4,7 @@ class Projects::BadgesController < Projects::ApplicationController
...
@@ -4,7 +4,7 @@ class Projects::BadgesController < Projects::ApplicationController
before_action
:no_cache_headers
,
except:
[
:index
]
before_action
:no_cache_headers
,
except:
[
:index
]
def
build
def
build
badge
=
Gitlab
::
Badge
::
Build
.
new
(
project
,
params
[
:ref
])
badge
=
Gitlab
::
Badge
::
Build
::
Status
.
new
(
project
,
params
[
:ref
])
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
render_404
}
format
.
html
{
render_404
}
...
...
app/controllers/projects/pipelines_settings_controller.rb
View file @
9f0b46c0
...
@@ -3,7 +3,7 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
...
@@ -3,7 +3,7 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
def
show
def
show
@ref
=
params
[
:ref
]
||
@project
.
default_branch
||
'master'
@ref
=
params
[
:ref
]
||
@project
.
default_branch
||
'master'
@build_badge
=
Gitlab
::
Badge
::
Build
.
new
(
@project
,
@ref
).
metadata
@build_badge
=
Gitlab
::
Badge
::
Build
::
Status
.
new
(
@project
,
@ref
).
metadata
end
end
def
update
def
update
...
...
lib/gitlab/badge/base.rb
0 → 100644
View file @
9f0b46c0
module
Gitlab
module
Badge
class
Base
def
key_text
raise
NotImplementedError
end
def
value_text
raise
NotImplementedError
end
def
metadata
raise
NotImplementedError
end
def
template
raise
NotImplementedError
end
end
end
end
lib/gitlab/badge/build.rb
deleted
100644 → 0
View file @
6f0b5800
module
Gitlab
module
Badge
##
# Build badge
#
class
Build
delegate
:key_text
,
:value_text
,
to: :template
def
initialize
(
project
,
ref
)
@project
=
project
@ref
=
ref
@sha
=
@project
.
commit
(
@ref
).
try
(
:sha
)
end
def
status
@project
.
pipelines
.
where
(
sha:
@sha
,
ref:
@ref
)
.
status
||
'unknown'
end
def
metadata
@metadata
||=
Build
::
Metadata
.
new
(
@project
,
@ref
)
end
def
template
@template
||=
Build
::
Template
.
new
(
status
)
end
end
end
end
lib/gitlab/badge/build/metadata.rb
View file @
9f0b46c0
module
Gitlab
module
Gitlab
module
Badge
module
Badge
class
Build
module
Build
##
##
# Class that describes build badge metadata
# Class that describes build badge metadata
#
#
...
...
lib/gitlab/badge/build/status.rb
0 → 100644
View file @
9f0b46c0
module
Gitlab
module
Badge
module
Build
##
# Build status badge
#
class
Status
<
Badge
::
Base
delegate
:key_text
,
:value_text
,
to: :template
def
initialize
(
project
,
ref
)
@project
=
project
@ref
=
ref
@sha
=
@project
.
commit
(
@ref
).
try
(
:sha
)
end
def
status
@project
.
pipelines
.
where
(
sha:
@sha
,
ref:
@ref
)
.
status
||
'unknown'
end
def
metadata
@metadata
||=
Build
::
Metadata
.
new
(
@project
,
@ref
)
end
def
template
@template
||=
Build
::
Template
.
new
(
status
)
end
end
end
end
end
lib/gitlab/badge/build/template.rb
View file @
9f0b46c0
module
Gitlab
module
Gitlab
module
Badge
module
Badge
class
Build
module
Build
##
##
# Class that represents a build badge template.
# Class that represents a build badge template.
#
#
...
...
lib/gitlab/badge/coverage.rb
deleted
100644 → 0
View file @
6f0b5800
module
Gitlab
module
Badge
##
# Test coverage badge
#
class
Coverage
def
initialize
(
project
,
ref
,
job
=
nil
)
@project
=
project
@ref
=
ref
@job
=
job
end
def
coverage
end
end
end
end
lib/gitlab/badge/coverage/report.rb
0 → 100644
View file @
9f0b46c0
module
Gitlab
module
Badge
module
Coverage
##
# Test coverage report badge
#
class
Report
<
Badge
::
Base
def
initialize
(
project
,
ref
,
job
=
nil
)
@project
=
project
@ref
=
ref
@job
=
job
end
def
coverage
end
end
end
end
end
spec/lib/gitlab/badge/build_spec.rb
→
spec/lib/gitlab/badge/build
/status
_spec.rb
View file @
9f0b46c0
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Badge
::
Build
do
describe
Gitlab
::
Badge
::
Build
::
Status
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sha
)
{
project
.
commit
.
sha
}
let
(
:sha
)
{
project
.
commit
.
sha
}
let
(
:branch
)
{
'master'
}
let
(
:branch
)
{
'master'
}
...
...
spec/lib/gitlab/badge/coverage_spec.rb
→
spec/lib/gitlab/badge/coverage
/report
_spec.rb
View file @
9f0b46c0
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Badge
::
Coverage
do
describe
Gitlab
::
Badge
::
Coverage
::
Report
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
let
(
:pipeline
)
do
...
@@ -9,11 +9,13 @@ describe Gitlab::Badge::Coverage do
...
@@ -9,11 +9,13 @@ describe Gitlab::Badge::Coverage do
ref:
'master'
)
ref:
'master'
)
end
end
let
(
:badge
)
{
described_class
.
new
(
project
,
'master'
)
}
let
(
:badge
)
do
described_class
.
new
(
project
,
'master'
)
end
context
'builds exist'
do
context
'builds exist'
do
end
end
context
'build
does
not exist'
do
context
'build
s do
not exist'
do
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