diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-26 18:09:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-26 18:09:45 +0000 |
commit | e7e40d45b066139707b3b851c6004e075da5226b (patch) | |
tree | cc99f48e2aaedbe9e8dac53fa4ca8d8f6f270bb4 /spec/models/commit_status_spec.rb | |
parent | aad3ac9e5e59d47e389ff387e9fc2ae3a008de33 (diff) | |
download | gitlab-ce-e7e40d45b066139707b3b851c6004e075da5226b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r-- | spec/models/commit_status_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index e64dee2d26f..feb2f3630c1 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -259,6 +259,40 @@ RSpec.describe CommitStatus do end end + describe '#queued_duration' do + subject { commit_status.queued_duration } + + around do |example| + travel_to(Time.current) { example.run } + end + + context 'when created, then enqueued, then started' do + before do + commit_status.queued_at = 30.seconds.ago + commit_status.started_at = 25.seconds.ago + end + + it { is_expected.to eq(5.0) } + end + + context 'when created but not yet enqueued' do + before do + commit_status.queued_at = nil + end + + it { is_expected.to be_nil } + end + + context 'when enqueued, but not started' do + before do + commit_status.queued_at = Time.current - 1.minute + commit_status.started_at = nil + end + + it { is_expected.to eq(1.minute) } + end + end + describe '.latest' do subject { described_class.latest.order(:id) } |