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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-12 03:10:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-12 03:10:11 +0300
commitc6f0b221b71133792f2c9e5a026f3744c16d5ef5 (patch)
tree864e5737806d454fbf23c681d5bced9b3e4a7d77 /spec/workers
parent3f45eb27e9586ad87682c2d125770e119a7e9fe0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/design_management/new_version_worker_spec.rb94
1 files changed, 94 insertions, 0 deletions
diff --git a/spec/workers/design_management/new_version_worker_spec.rb b/spec/workers/design_management/new_version_worker_spec.rb
new file mode 100644
index 00000000000..76497dde464
--- /dev/null
+++ b/spec/workers/design_management/new_version_worker_spec.rb
@@ -0,0 +1,94 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe DesignManagement::NewVersionWorker do
+ # TODO a number of these tests are being temporarily skipped unless run in EE,
+ # as we are in the process of moving Design Management to FOSS in 13.0
+ # in steps. In the current step the services have not yet been moved, and
+ # certain services are called within these tests:
+ # - `SystemNoteService`
+ # - `DesignManagement::GenerateImageVersionsService`
+ #
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283.
+ describe '#perform' do
+ let(:worker) { described_class.new }
+
+ context 'the id is wrong or out-of-date' do
+ let(:version_id) { -1 }
+
+ it 'does not create system notes' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect(SystemNoteService).not_to receive(:design_version_added)
+
+ worker.perform(version_id)
+ end
+
+ it 'does not invoke GenerateImageVersionsService' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect(DesignManagement::GenerateImageVersionsService).not_to receive(:new)
+
+ worker.perform(version_id)
+ end
+
+ it 'logs the reason for this failure' do
+ expect(Sidekiq.logger).to receive(:warn)
+ .with(an_instance_of(ActiveRecord::RecordNotFound))
+
+ worker.perform(version_id)
+ end
+ end
+
+ context 'the version id is valid' do
+ let_it_be(:version) { create(:design_version, :with_lfs_file, designs_count: 2) }
+
+ it 'creates a system note' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect { worker.perform(version.id) }.to change { Note.system.count }.by(1)
+ end
+
+ it 'invokes GenerateImageVersionsService' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect_next_instance_of(DesignManagement::GenerateImageVersionsService) do |service|
+ expect(service).to receive(:execute)
+ end
+
+ worker.perform(version.id)
+ end
+
+ it 'does not log anything' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect(Sidekiq.logger).not_to receive(:warn)
+
+ worker.perform(version.id)
+ end
+ end
+
+ context 'the version includes multiple types of action' do
+ let_it_be(:version) do
+ create(:design_version, :with_lfs_file,
+ created_designs: create_list(:design, 1, :with_lfs_file),
+ modified_designs: create_list(:design, 1))
+ end
+
+ it 'creates two system notes' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect { worker.perform(version.id) }.to change { Note.system.count }.by(2)
+ end
+
+ it 'calls design_version_added' do
+ skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
+
+ expect(SystemNoteService).to receive(:design_version_added).with(version)
+
+ worker.perform(version.id)
+ end
+ end
+ end
+end