diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-30 02:54:07 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-30 02:54:07 +0800 |
commit | 031b162392c074b0bff1a5d4239acd8026592fdd (patch) | |
tree | acfc110a0a744248314a8542a91115881f64ddbf | |
parent | 7e32e2ef20feb9c2bbc1b1504cc56c9185621c86 (diff) | |
download | gitlab-ce-031b162392c074b0bff1a5d4239acd8026592fdd.tar.gz |
Fix test for Pipeline#duration
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 721b20e0cb2..a34b9cb4461 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -124,17 +124,22 @@ describe Ci::Pipeline, models: true do describe 'state machine' do let(:current) { Time.now.change(usec: 0) } - let(:build) { create :ci_build, name: 'build1', pipeline: pipeline } + let(:build) { create_build('build1', current - 60) } + let(:another_build) { create_build('build2', current + 20) } describe '#duration' do before do - travel_to(current - 120) do - pipeline.run - end + pipeline.run travel_to(current) do - pipeline.succeed + build.success + end + + travel_to(current + 80) do + another_build.drop end + + pipeline.drop end it 'matches sum of builds duration' do @@ -169,6 +174,13 @@ describe Ci::Pipeline, models: true do expect(pipeline.reload.finished_at).to be_nil end end + + def create_build(name, started_at = current) + create(:ci_build, + name: name, + pipeline: pipeline, + started_at: started_at) + end end describe '#branch?' do |