2020-06-23 00:09:42 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Integrations::PropagateService, feature_category: :integrations do
|
2020-06-23 00:09:42 +05:30
|
|
|
describe '.propagate' do
|
2022-07-23 23:45:48 +05:30
|
|
|
include JiraIntegrationHelpers
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
before do
|
2021-09-30 23:02:18 +05:30
|
|
|
stub_jira_integration_test
|
2020-11-24 15:15:51 +05:30
|
|
|
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) }
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:instance_integration) { create(:jira_integration, :instance) }
|
|
|
|
let_it_be(:not_inherited_integration) { create(:jira_integration, project: project) }
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:inherited_integration) do
|
2021-09-30 23:02:18 +05:30
|
|
|
create(:jira_integration, project: create(:project), inherit_from_id: instance_integration.id)
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:different_type_inherited_integration) do
|
2021-09-30 23:02:18 +05:30
|
|
|
create(:redmine_integration, 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
|
2021-12-11 22:18:48 +05:30
|
|
|
let(:group_integration) { create(:jira_integration, :group, group: group) }
|
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-29 00:20:46 +05:30
|
|
|
context 'with a subgroup without integration' do
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
context 'with a subgroup with integration' do
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
2021-12-11 22:18:48 +05:30
|
|
|
let(:subgroup_integration) { create(:jira_integration, :group, group: subgroup, inherit_from_id: group_integration.id) }
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
it 'calls to PropagateIntegrationInheritDescendantWorker' do
|
|
|
|
expect(PropagateIntegrationInheritDescendantWorker).to receive(:perform_async)
|
|
|
|
.with(group_integration.id, subgroup_integration.id, subgroup_integration.id)
|
|
|
|
|
|
|
|
described_class.propagate(group_integration)
|
|
|
|
end
|
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|