diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 16:47:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 16:47:14 +0300 |
commit | 022f9b6b0c3771d0c8f1c4cb5d15258119fddc2a (patch) | |
tree | 4c205cedfd196fb0fe23a794bc6effb8f8d6ef21 /spec/workers | |
parent | 88bbc405d6b46a477d6dddf4f1416240640f70d1 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-ee
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb b/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb new file mode 100644 index 00000000000..fcf57e21ac9 --- /dev/null +++ b/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::InitializePipelinesIidSequenceWorker, feature_category: :continuous_integration do + let_it_be_with_refind(:project) { create(:project) } + + let(:project_created_event) do + Projects::ProjectCreatedEvent.new( + data: { + project_id: project.id, + namespace_id: project.namespace_id, + root_namespace_id: project.root_namespace.id + }) + end + + it_behaves_like 'subscribes to event' do + let(:event) { project_created_event } + end + + it 'creates an internal_ids sequence for ci_pipelines' do + consume_event(subscriber: described_class, event: project_created_event) + + expect(project.internal_ids.ci_pipelines).to be_any + expect(project.internal_ids.ci_pipelines).to all be_persisted + end + + context 'when the internal_ids sequence is already initialized' do + before do + create_list(:ci_pipeline, 2, project: project) + end + + it 'does not reset the sequence' do + expect { consume_event(subscriber: described_class, event: project_created_event) } + .not_to change { project.internal_ids.ci_pipelines.pluck(:last_value) } + end + end +end |