diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-19 20:42:26 +0300 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-08-19 23:36:56 +0300 |
commit | f81dd64f13e5e36c075a42a5411640127b94727b (patch) | |
tree | 0315de2d6a26c47f42aaa3dbe5e68234092f5d03 /spec | |
parent | 9d71605ba53ba365e4b60880d4bd5dda7a40d22d (diff) |
Merge branch 'wall-clock-time-for-showing-pipeline' into 'master'
Show wall-clock time when showing pipeline
Show wall-clock time when showing pipeline instead of cumulative builds time.
Closes #17007
See merge request !5734
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/time_helper_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/broadcast_message_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 14 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 |
4 files changed, 18 insertions, 15 deletions
diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb index bf3ed5c094c..21f35585367 100644 --- a/spec/helpers/time_helper_spec.rb +++ b/spec/helpers/time_helper_spec.rb @@ -19,16 +19,16 @@ describe TimeHelper do describe "#duration_in_numbers" do it "returns minutes and seconds" do - duration_in_numbers = { - [100, 0] => "01:40", - [121, 0] => "02:01", - [3721, 0] => "01:02:01", - [0, 0] => "00:00", - [nil, Time.now.to_i - 42] => "00:42" + durations_and_expectations = { + 100 => "01:40", + 121 => "02:01", + 3721 => "01:02:01", + 0 => "00:00", + 42 => "00:42" } - duration_in_numbers.each do |interval, expectation| - expect(duration_in_numbers(*interval)).to eq(expectation) + durations_and_expectations.each do |duration, expectation| + expect(duration_in_numbers(duration)).to eq(expectation) end end end diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb index 72688137f08..02d6263094a 100644 --- a/spec/models/broadcast_message_spec.rb +++ b/spec/models/broadcast_message_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe BroadcastMessage, models: true do - include ActiveSupport::Testing::TimeHelpers - subject { create(:broadcast_message) } it { is_expected.to be_valid } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 950833cb219..a0df0224e08 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -122,17 +122,21 @@ 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, started_at: current - 60, finished_at: current } - let(:build2) { create :ci_build, name: 'build2', pipeline: pipeline, started_at: current - 60, finished_at: current } + let(:build) { create :ci_build, name: 'build1', pipeline: pipeline } describe '#duration' do before do - build.skip - build2.skip + travel_to(current - 120) do + pipeline.run + end + + travel_to(current) do + pipeline.succeed + end end it 'matches sum of builds duration' do - expect(pipeline.reload.duration).to eq(build.duration + build2.duration) + expect(pipeline.reload.duration).to eq(120) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e2aa7c4fc0..c144cd85487 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -33,6 +33,7 @@ RSpec.configure do |config| config.include EmailHelpers config.include TestEnv config.include ActiveJob::TestHelper + config.include ActiveSupport::Testing::TimeHelpers config.include StubGitlabCalls config.include StubGitlabData |