diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/models/commit_status_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
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) } |