Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2018-04-10 15:19:41 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2018-04-10 16:13:55 +0300
commit2cc0c692c082fddabcbb5ddc51e46d7996f5c3d7 (patch)
treea169d5aa280794a1fa94424c45b59df4a87d64bc /spec/models/commit_status_spec.rb
parent2c7f0766640af870500c7d681460c754ac938b1c (diff)
Ensure that enqueuing a commit status always sets 'queued_at' value
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r--spec/models/commit_status_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index c536dab2681..2ed29052dc1 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -533,4 +533,36 @@ describe CommitStatus do
end
end
end
+
+ describe '#enqueue' do
+ let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) }
+
+ before do
+ allow(Time).to receive(:now).and_return(current_time)
+ end
+
+ shared_examples 'commit status enqueued' do
+ it 'sets queued_at value when enqueued' do
+ expect { commit_status.enqueue }.to change { commit_status.reload.queued_at }.from(nil).to(current_time)
+ end
+ end
+
+ context 'when initial state is :created' do
+ let(:commit_status) { create(:commit_status, :created) }
+
+ it_behaves_like 'commit status enqueued'
+ end
+
+ context 'when initial state is :skipped' do
+ let(:commit_status) { create(:commit_status, :skipped) }
+
+ it_behaves_like 'commit status enqueued'
+ end
+
+ context 'when initial state is :manual' do
+ let(:commit_status) { create(:commit_status, :manual) }
+
+ it_behaves_like 'commit status enqueued'
+ end
+ end
end