diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-26 15:48:51 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-26 15:48:51 +0300 |
commit | 744d291de7f7387564900c77999d6d6b712e1837 (patch) | |
tree | 9a5d465b05dbb6e00c735d567c1a10bea0d0536e /spec | |
parent | d4848d8f29da286f45338088b3f901544d3584c8 (diff) | |
download | gitlab-ci-744d291de7f7387564900c77999d6d6b712e1837.tar.gz |
fix coverage calculation on commit page
Diffstat (limited to 'spec')
-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 |