diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/services/design_management | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/services/design_management')
-rw-r--r-- | spec/services/design_management/copy_design_collection/copy_service_spec.rb | 37 | ||||
-rw-r--r-- | spec/services/design_management/generate_image_versions_service_spec.rb | 2 |
2 files changed, 32 insertions, 7 deletions
diff --git a/spec/services/design_management/copy_design_collection/copy_service_spec.rb b/spec/services/design_management/copy_design_collection/copy_service_spec.rb index e93e5f13fea..ddbed91815f 100644 --- a/spec/services/design_management/copy_design_collection/copy_service_spec.rb +++ b/spec/services/design_management/copy_design_collection/copy_service_spec.rb @@ -68,6 +68,31 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla include_examples 'service error', message: 'Target design collection already has designs' end + context 'when target project already has designs' do + let!(:issue_x) { create(:issue, project: target_issue.project) } + let!(:existing) { create(:design, issue: issue_x, project: target_issue.project) } + + let(:new_designs) do + target_issue.reset + target_issue.designs.where.not(id: existing.id) + end + + it 'sets IIDs for new designs above existing ones' do + subject + + expect(new_designs).to all(have_attributes(iid: (be > existing.iid))) + end + + it 'does not allow for IID collisions' do + subject + create(:design, issue: issue_x, project: target_issue.project) + + design_iids = target_issue.project.designs.map(&:id) + + expect(design_iids).to match_array(design_iids.uniq) + end + end + include_examples 'service success' it 'creates a design repository for the target project' do @@ -162,9 +187,7 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla it 'copies the Git repository data', :aggregate_failures do subject - commit_shas = target_repository.commits('master', limit: 99).map(&:id) - - expect(commit_shas).to include(*target_issue.design_versions.ordered.pluck(:sha)) + expect(commits_on_master(limit: 99)).to include(*target_issue.design_versions.ordered.pluck(:sha)) end it 'creates a master branch if none previously existed' do @@ -212,9 +235,7 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla issue_2 = create(:issue, project: target_issue.project) create(:design, :with_file, issue: issue_2, project: target_issue.project) - expect { subject }.not_to change { - expect(target_repository.commits('master', limit: 10).size).to eq(1) - } + expect { subject }.not_to change { commits_on_master } end it 'sets the design collection copy state' do @@ -223,6 +244,10 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla expect(target_issue.design_collection).to be_copy_error end end + + def commits_on_master(limit: 10) + target_repository.commits('master', limit: limit).map(&:id) + end end end end diff --git a/spec/services/design_management/generate_image_versions_service_spec.rb b/spec/services/design_management/generate_image_versions_service_spec.rb index 749030af97d..e06b6fbf116 100644 --- a/spec/services/design_management/generate_image_versions_service_spec.rb +++ b/spec/services/design_management/generate_image_versions_service_spec.rb @@ -44,7 +44,7 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do end it 'logs if the raw image cannot be found' do - version.designs.first.update(filename: 'foo.png') + version.designs.first.update!(filename: 'foo.png') expect(Gitlab::AppLogger).to receive(:error).with("No design file found for Action: #{action.id}") |