Skip to content
Snippets Groups Projects
Commit 52e0d475 authored by Valery Sizov's avatar Valery Sizov
Browse files

Merge branch 'coverage' into 'master'

Rounded coverage on commit page

https://dev.gitlab.org/gitlab/gitlab-ci/issues/312

See merge request !184
parents 859e0b41 25729b09
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -208,7 +208,7 @@ class Commit < ActiveRecord::Base
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
'%.2f' % (coverage_array.reduce(:+) / coverage_array.size)
end
end
end
Loading
Loading
Loading
Loading
@@ -167,14 +167,14 @@ describe Commit do
it "calculates average when there are two builds with coverage" do
FactoryGirl.create :build, coverage: 30, commit: commit
FactoryGirl.create :build, coverage: 40, commit: commit
commit.coverage.should == 35.0
commit.coverage.should == "35.00"
end
 
it "calculates average when there are two builds with coverage and one with nil" do
FactoryGirl.create :build, coverage: 30, commit: commit
FactoryGirl.create :build, coverage: 40, commit: commit
FactoryGirl.create :build, commit: commit
commit.coverage.should == 35.0
commit.coverage.should == "35.00"
end
 
it "calculates average when there is one build without coverage" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment