summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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