summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-07-01 10:56:56 +0300
committerValery Sizov <vsv2711@gmail.com>2015-07-01 11:01:23 +0300
commit25729b09ed352fcb8ef505f58edfc0f97c4ef42b (patch)
tree4016ebac73b98e0bdf9a2acd8123cc0ab8ab733e
parent859e0b41ee10d7ca23297fdd964eca5949e25c12 (diff)
downloadgitlab-ci-25729b09ed352fcb8ef505f58edfc0f97c4ef42b.tar.gz
Rounded coverage on commit page
-rw-r--r--app/models/commit.rb2
-rw-r--r--spec/models/commit_spec.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index d5485cd..73e485a 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -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
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index e1969c4..76d3178 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -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