diff options
author | Valery Sizov <valery@gitlab.com> | 2015-06-26 13:03:30 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-06-26 13:03:30 +0000 |
commit | c4657e482bfe68b59235214220a9aa294b16d104 (patch) | |
tree | ff70acb9732acf762d0a4974efd24c5354b1351e /spec/models/commit_spec.rb | |
parent | 07383304a5d0593875025c3317e1914efe74b7f6 (diff) | |
parent | 744d291de7f7387564900c77999d6d6b712e1837 (diff) | |
download | gitlab-ci-c4657e482bfe68b59235214220a9aa294b16d104.tar.gz |
Merge branch 'coverage_fix' into 'master'
Fix coverage colcalation on the commit page
See merge request !171
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 8c0073e..e1969c4 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -159,4 +159,27 @@ describe Commit do commit.finished_at.should be_nil end end + + describe "coverage" do + let(:project) { FactoryGirl.create :project, coverage_regex: "/.*/" } + let(:commit) { FactoryGirl.create :commit, project: project } + + 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 + 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 + end + + it "calculates average when there is one build without coverage" do + FactoryGirl.create :build, commit: commit + commit.coverage.should be_nil + end + end end |