Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge branch 'coverage' into 'master'
Browse files Browse the repository at this point in the history
Rounded coverage on commit page

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

See merge request !184
  • Loading branch information
vsizov committed Jul 1, 2015
2 parents 859e0b4 + 25729b0 commit 52e0d47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/commit.rb
Expand Up @@ -208,7 +208,7 @@ def 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
'%.2f' % (coverage_array.reduce(:+) / coverage_array.size)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/commit_spec.rb
Expand Up @@ -167,14 +167,14 @@
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
Expand Down

0 comments on commit 52e0d47

Please sign in to comment.