diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-30 21:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-30 21:08:56 +0300 |
commit | 98d7cc758fb73239fb957c297446c811ab4150d9 (patch) | |
tree | 227a5e8efe35d2ac158e762397609a3f1754b224 /spec/services/bulk_create_integration_service_spec.rb | |
parent | 038366a0932c5f88019cc3db85382f26af3933e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/bulk_create_integration_service_spec.rb')
-rw-r--r-- | spec/services/bulk_create_integration_service_spec.rb | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/spec/services/bulk_create_integration_service_spec.rb b/spec/services/bulk_create_integration_service_spec.rb index 6278f00e878..674382ee14f 100644 --- a/spec/services/bulk_create_integration_service_spec.rb +++ b/spec/services/bulk_create_integration_service_spec.rb @@ -5,12 +5,14 @@ require 'spec_helper' RSpec.describe BulkCreateIntegrationService do include JiraServiceHelper - before do + before_all do stub_jira_service_test end - let_it_be(:instance_integration) { create(:jira_service, :instance) } - let_it_be(:template_integration) { create(:jira_service, :template) } + let_it_be(:excluded_group) { create(:group) } + let_it_be(:excluded_project) { create(:project, group: excluded_group) } + let(:instance_integration) { create(:jira_service, :instance) } + let(:template_integration) { create(:jira_service, :template) } let(:excluded_attributes) { %w[id project_id group_id inherit_from_id instance template created_at updated_at] } shared_examples 'creates integration from batch ids' do @@ -46,15 +48,19 @@ RSpec.describe BulkCreateIntegrationService do described_class.new(integration, batch, association).execute expect(project.reload.has_external_issue_tracker).to eq(true) + expect(excluded_project.reload.has_external_issue_tracker).to eq(false) end context 'with an external wiki integration' do - let(:integration) { create(:external_wiki_service, :instance) } + before do + integration.update!(category: 'common', type: 'ExternalWikiService') + end it 'updates projects#has_external_wiki for external wiki services' do described_class.new(integration, batch, association).execute expect(project.reload.has_external_wiki).to eq(true) + expect(excluded_project.reload.has_external_wiki).to eq(false) end end end @@ -77,14 +83,14 @@ RSpec.describe BulkCreateIntegrationService do end end - context 'with an instance-level integration' do + context 'passing an instance-level integration' do let(:integration) { instance_integration } let(:inherit_from_id) { integration.id } context 'with a project association' do let!(:project) { create(:project) } let(:created_integration) { project.jira_service } - let(:batch) { Project.without_integration(integration) } + let(:batch) { Project.where(id: project.id) } let(:association) { 'project' } it_behaves_like 'creates integration from batch ids' @@ -101,36 +107,52 @@ RSpec.describe BulkCreateIntegrationService do end context 'with a group association' do - let_it_be(:group) { create(:group) } + let!(:group) { create(:group) } let(:created_integration) { Service.find_by(group: group) } - let(:batch) { Group.all } + let(:batch) { Group.where(id: group.id) } let(:association) { 'group' } it_behaves_like 'creates integration from batch ids' it_behaves_like 'updates inherit_from_id' + end + end - context 'with a subgroup association' do - let_it_be(:group_integration) { create(:jira_service, group: group, project: nil, inherit_from_id: instance_integration.id) } - let_it_be(:subgroup) { create(:group, parent: group) } - let(:integration) { group_integration } - let(:created_integration) { Service.find_by(group: subgroup) } - let(:batch) { Group.all } - let(:association) { 'group' } - let(:inherit_from_id) { instance_integration.id } - - it_behaves_like 'creates integration from batch ids' - it_behaves_like 'updates inherit_from_id' - end + context 'passing a group integration' do + let_it_be(:group) { create(:group) } + + context 'with a project association' do + let!(:project) { create(:project, group: group) } + let(:integration) { create(:jira_service, group: group, project: nil) } + let(:created_integration) { project.jira_service } + let(:batch) { Project.where(id: Project.minimum(:id)..Project.maximum(:id)).without_integration(integration).in_namespace(integration.group.self_and_descendants) } + let(:association) { 'project' } + let(:inherit_from_id) { integration.id } + + it_behaves_like 'creates integration from batch ids' + it_behaves_like 'updates inherit_from_id' + it_behaves_like 'updates project callbacks' + end + + context 'with a group association' do + let!(:subgroup) { create(:group, parent: group) } + let(:integration) { create(:jira_service, group: group, project: nil, inherit_from_id: instance_integration.id) } + let(:created_integration) { Service.find_by(group: subgroup) } + let(:batch) { Group.where(id: subgroup.id) } + let(:association) { 'group' } + let(:inherit_from_id) { instance_integration.id } + + it_behaves_like 'creates integration from batch ids' + it_behaves_like 'updates inherit_from_id' end end - context 'with a template integration' do + context 'passing a template integration' do let(:integration) { template_integration } context 'with a project association' do let!(:project) { create(:project) } let(:created_integration) { project.jira_service } - let(:batch) { Project.all } + let(:batch) { Project.where(id: project.id) } let(:association) { 'project' } let(:inherit_from_id) { integration.id } |