summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-06-26 15:48:51 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-26 15:48:51 +0300
commit744d291de7f7387564900c77999d6d6b712e1837 (patch)
tree9a5d465b05dbb6e00c735d567c1a10bea0d0536e /app/models/commit.rb
parentd4848d8f29da286f45338088b3f901544d3584c8 (diff)
downloadgitlab-ci-744d291de7f7387564900c77999d6d6b712e1837.tar.gz
fix coverage calculation on commit page
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 215afdd..7cf2810 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -205,8 +205,11 @@ class Commit < ActiveRecord::Base
end
def coverage
- if project.coverage_enabled? && builds.size > 0
- builds.last.coverage
+ if project.coverage_enabled? && builds.count(:all) > 0
+ coverage_array = builds.map(&:coverage).compact
+ if coverage_array.size > 1
+ coverage_array.reduce(:+) / coverage_array.size
+ end
end
end