debian-mirror-gitlab/spec/services/admin/propagate_integration_service_spec.rb

83 lines
2.8 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::PropagateIntegrationService do
describe '.propagate' do
2020-11-24 15:15:51 +05:30
include JiraServiceHelper
before do
stub_jira_service_test
end
2021-01-03 14:25:43 +05:30
let(:group) { create(:group) }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
let_it_be(:project) { create(:project) }
let_it_be(:instance_integration) { create(:jira_service, :instance) }
let_it_be(:not_inherited_integration) { create(:jira_service, project: project) }
let_it_be(:inherited_integration) do
create(:jira_service, project: create(:project), inherit_from_id: instance_integration.id)
2020-06-23 00:09:42 +05:30
end
2021-01-03 14:25:43 +05:30
let_it_be(:different_type_inherited_integration) do
create(:redmine_service, project: project, inherit_from_id: instance_integration.id)
2020-06-23 00:09:42 +05:30
end
2021-01-03 14:25:43 +05:30
context 'with inherited integration' do
let(:integration) { inherited_integration }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationInheritWorker).to receive(:perform_async)
.with(instance_integration.id, inherited_integration.id, inherited_integration.id)
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
described_class.propagate(instance_integration)
2020-06-23 00:09:42 +05:30
end
2021-01-03 14:25:43 +05:30
end
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
context 'with a project without integration' do
let(:another_project) { create(:project) }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(instance_integration.id, another_project.id, another_project.id)
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
described_class.propagate(instance_integration)
2020-06-23 00:09:42 +05:30
end
end
2021-01-03 14:25:43 +05:30
context 'with a group without integration' do
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationGroupWorker).to receive(:perform_async)
.with(instance_integration.id, group.id, group.id)
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
described_class.propagate(instance_integration)
2020-06-23 00:09:42 +05:30
end
end
2021-01-03 14:25:43 +05:30
context 'for a group-level integration' do
let(:group_integration) { create(:jira_service, group: group, project: nil) }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
context 'with a project without integration' do
let(:another_project) { create(:project, group: group) }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(group_integration.id, another_project.id, another_project.id)
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
described_class.propagate(group_integration)
end
2020-06-23 00:09:42 +05:30
end
2021-01-03 14:25:43 +05:30
context 'with a group without integration' do
let(:subgroup) { create(:group, parent: group) }
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationGroupWorker' do
expect(PropagateIntegrationGroupWorker).to receive(:perform_async)
.with(group_integration.id, subgroup.id, subgroup.id)
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
described_class.propagate(group_integration)
end
end
2020-06-23 00:09:42 +05:30
end
end
end