diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-08 13:38:36 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-08 13:38:36 +0300 |
commit | bc17996227117bcaf11dc41a0dd2b2f11a7329f4 (patch) | |
tree | 0afb39f69d0f5a9f6c022466d470e4c09a8e56b5 /lib/gitlab/badge | |
parent | 8ae222092dc63d672dc505358d7bdfbb8478c774 (diff) |
Improve builds badge specs, remove legacy methods
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r-- | lib/gitlab/badge/build.rb | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb index c94ef3e9678..1de721a2269 100644 --- a/lib/gitlab/badge/build.rb +++ b/lib/gitlab/badge/build.rb @@ -4,35 +4,26 @@ module Gitlab # 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 - sha = @project.commit(@ref).try(:sha) - @project.pipelines - .where(sha: sha, ref: @ref) + .where(sha: @sha, ref: @ref) .status || 'unknown' end def metadata - Build::Metadata.new(@project, @ref) + @metadata ||= Build::Metadata.new(@project, @ref) end def template - Build::Template.new(status) - end - - def type - 'image/svg+xml' - end - - def data - File.read( - Rails.root.join('public/ci', 'build-' + status + '.svg') - ) + @template ||= Build::Template.new(status) end end end |