Commit c06be029 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '345017-integrations-factory-group-trait' into 'master'

Add :group trait for integrations factories

See merge request gitlab-org/gitlab!74142
parents 29472ba1 155b3167
...@@ -78,7 +78,7 @@ RSpec.describe Groups::Settings::IntegrationsController do ...@@ -78,7 +78,7 @@ RSpec.describe Groups::Settings::IntegrationsController do
describe '#update' do describe '#update' do
include JiraServiceHelper include JiraServiceHelper
let(:integration) { create(:jira_integration, project: nil, group_id: group.id) } let(:integration) { create(:jira_integration, :group, group: group) }
before do before do
group.add_owner(user) group.add_owner(user)
...@@ -108,7 +108,7 @@ RSpec.describe Groups::Settings::IntegrationsController do ...@@ -108,7 +108,7 @@ RSpec.describe Groups::Settings::IntegrationsController do
end end
describe '#reset' do describe '#reset' do
let_it_be(:integration) { create(:jira_integration, group: group, project: nil) } let_it_be(:integration) { create(:jira_integration, :group, group: group) }
let_it_be(:inheriting_integration) { create(:jira_integration, inherit_from_id: integration.id) } let_it_be(:inheriting_integration) { create(:jira_integration, inherit_from_id: integration.id) }
subject do subject do
......
...@@ -254,7 +254,7 @@ RSpec.describe Projects::ServicesController do ...@@ -254,7 +254,7 @@ RSpec.describe Projects::ServicesController do
let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
let_it_be(:jira_integration) { create(:jira_integration, project: project) } let_it_be(:jira_integration) { create(:jira_integration, project: project) }
let(:group_integration) { create(:jira_integration, group: group, project: nil, url: 'http://group.com', password: 'group') } let(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.com', password: 'group') }
let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } } let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } }
it 'ignores submitted params and inherits group settings' do it 'ignores submitted params and inherits group settings' do
...@@ -269,7 +269,7 @@ RSpec.describe Projects::ServicesController do ...@@ -269,7 +269,7 @@ RSpec.describe Projects::ServicesController do
context 'when param `inherit_from_id` is set to an unrelated group' do context 'when param `inherit_from_id` is set to an unrelated group' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let(:group_integration) { create(:jira_integration, group: group, project: nil, url: 'http://group.com', password: 'group') } let(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.com', password: 'group') }
let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } } let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } }
it 'ignores the param and saves the submitted settings' do it 'ignores the param and saves the submitted settings' do
......
...@@ -222,6 +222,11 @@ FactoryBot.define do ...@@ -222,6 +222,11 @@ FactoryBot.define do
template { true } template { true }
end end
trait :group do
group
project { nil }
end
trait :instance do trait :instance do
project { nil } project { nil }
instance { true } instance { true }
......
...@@ -84,7 +84,7 @@ RSpec.describe 'User uses inherited settings', :js do ...@@ -84,7 +84,7 @@ RSpec.describe 'User uses inherited settings', :js do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
let_it_be(:parent_settings) { { url: 'http://group.com', password: 'group' } } let_it_be(:parent_settings) { { url: 'http://group.com', password: 'group' } }
let_it_be(:parent_integration) { create(:jira_integration, group: group, project: nil, **parent_settings) } let_it_be(:parent_integration) { create(:jira_integration, :group, group: group, **parent_settings) }
it_behaves_like 'inherited settings' it_behaves_like 'inherited settings'
end end
......
...@@ -50,7 +50,7 @@ RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do ...@@ -50,7 +50,7 @@ RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do
describe 'a group integration' do describe 'a group integration' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:integration) { create(:prometheus_integration, project: nil, group: group) } let_it_be(:integration) { create(:prometheus_integration, :group, group: group) }
# Since it is impossible to authorize the parent here, given that the # Since it is impossible to authorize the parent here, given that the
# project is nil, all fields should be redacted: # project is nil, all fields should be redacted:
......
...@@ -12,7 +12,7 @@ RSpec.describe HasIntegrations do ...@@ -12,7 +12,7 @@ RSpec.describe HasIntegrations do
before do before do
create(:jira_integration, project: project_1, inherit_from_id: instance_integration.id) create(:jira_integration, project: project_1, inherit_from_id: instance_integration.id)
create(:jira_integration, project: project_2, inherit_from_id: nil) create(:jira_integration, project: project_2, inherit_from_id: nil)
create(:jira_integration, group: create(:group), project: nil, inherit_from_id: nil) create(:jira_integration, :group, group: create(:group), inherit_from_id: nil)
create(:jira_integration, project: project_3, inherit_from_id: nil) create(:jira_integration, project: project_3, inherit_from_id: nil)
create(:integrations_slack, project: project_4, inherit_from_id: nil) create(:integrations_slack, project: project_4, inherit_from_id: nil)
end end
......
...@@ -582,8 +582,8 @@ RSpec.describe Group do ...@@ -582,8 +582,8 @@ RSpec.describe Group do
let(:instance_integration) { build(:jira_integration, :instance) } let(:instance_integration) { build(:jira_integration, :instance) }
before do before do
create(:jira_integration, group: group, project: nil) create(:jira_integration, :group, group: group)
create(:integrations_slack, group: another_group, project: nil) create(:integrations_slack, :group, group: another_group)
end end
it 'returns groups without integration' do it 'returns groups without integration' do
......
...@@ -299,7 +299,7 @@ RSpec.describe Integration do ...@@ -299,7 +299,7 @@ RSpec.describe Integration do
end end
context 'when integration is a group-level integration' do context 'when integration is a group-level integration' do
let(:group_integration) { create(:jira_integration, group: group, project: nil) } let(:group_integration) { create(:jira_integration, :group, group: group) }
it 'sets inherit_from_id from integration' do it 'sets inherit_from_id from integration' do
integration = described_class.build_from_integration(group_integration, project_id: project.id) integration = described_class.build_from_integration(group_integration, project_id: project.id)
...@@ -458,7 +458,7 @@ RSpec.describe Integration do ...@@ -458,7 +458,7 @@ RSpec.describe Integration do
end end
context 'with an active group-level integration' do context 'with an active group-level integration' do
let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') } let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
it 'creates an integration from the group-level integration' do it 'creates an integration from the group-level integration' do
described_class.create_from_active_default_integrations(project, :project_id) described_class.create_from_active_default_integrations(project, :project_id)
...@@ -481,7 +481,7 @@ RSpec.describe Integration do ...@@ -481,7 +481,7 @@ RSpec.describe Integration do
end end
context 'with an active subgroup' do context 'with an active subgroup' do
let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') } let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let!(:subgroup) { create(:group, parent: group) } let!(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, group: subgroup) } let(:project) { create(:project, group: subgroup) }
...@@ -509,7 +509,7 @@ RSpec.describe Integration do ...@@ -509,7 +509,7 @@ RSpec.describe Integration do
end end
context 'having an integration inheriting settings' do context 'having an integration inheriting settings' do
let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id, api_url: 'https://prometheus.subgroup.com/') } let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, inherit_from_id: group_integration.id, api_url: 'https://prometheus.subgroup.com/') }
it 'creates an integration from the group-level integration' do it 'creates an integration from the group-level integration' do
described_class.create_from_active_default_integrations(sub_subgroup, :group_id) described_class.create_from_active_default_integrations(sub_subgroup, :group_id)
...@@ -552,11 +552,11 @@ RSpec.describe Integration do ...@@ -552,11 +552,11 @@ RSpec.describe Integration do
let_it_be(:subgroup2) { create(:group, parent: group) } let_it_be(:subgroup2) { create(:group, parent: group) }
let_it_be(:project1) { create(:project, group: subgroup1) } let_it_be(:project1) { create(:project, group: subgroup1) }
let_it_be(:project2) { create(:project, group: subgroup2) } let_it_be(:project2) { create(:project, group: subgroup2) }
let_it_be(:group_integration) { create(:prometheus_integration, group: group, project: nil) } let_it_be(:group_integration) { create(:prometheus_integration, :group, group: group) }
let_it_be(:subgroup_integration1) { create(:prometheus_integration, group: subgroup1, project: nil, inherit_from_id: group_integration.id) } let_it_be(:subgroup_integration1) { create(:prometheus_integration, :group, group: subgroup1, inherit_from_id: group_integration.id) }
let_it_be(:subgroup_integration2) { create(:prometheus_integration, group: subgroup2, project: nil) } let_it_be(:subgroup_integration2) { create(:prometheus_integration, :group, group: subgroup2) }
let_it_be(:project_integration1) { create(:prometheus_integration, group: nil, project: project1, inherit_from_id: group_integration.id) } let_it_be(:project_integration1) { create(:prometheus_integration, project: project1, inherit_from_id: group_integration.id) }
let_it_be(:project_integration2) { create(:prometheus_integration, group: nil, project: project2, inherit_from_id: subgroup_integration2.id) } let_it_be(:project_integration2) { create(:prometheus_integration, project: project2, inherit_from_id: subgroup_integration2.id) }
it 'returns the groups and projects inheriting from integration ancestors', :aggregate_failures do it 'returns the groups and projects inheriting from integration ancestors', :aggregate_failures do
expect(described_class.inherited_descendants_from_self_or_ancestors_from(group_integration)).to eq([subgroup_integration1, project_integration1]) expect(described_class.inherited_descendants_from_self_or_ancestors_from(group_integration)).to eq([subgroup_integration1, project_integration1])
......
...@@ -55,7 +55,7 @@ RSpec.describe Admin::PropagateIntegrationService do ...@@ -55,7 +55,7 @@ RSpec.describe Admin::PropagateIntegrationService do
end end
context 'for a group-level integration' do context 'for a group-level integration' do
let(:group_integration) { create(:jira_integration, group: group, project: nil) } let(:group_integration) { create(:jira_integration, :group, group: group) }
context 'with a project without integration' do context 'with a project without integration' do
let(:another_project) { create(:project, group: group) } let(:another_project) { create(:project, group: group) }
...@@ -81,7 +81,7 @@ RSpec.describe Admin::PropagateIntegrationService do ...@@ -81,7 +81,7 @@ RSpec.describe Admin::PropagateIntegrationService do
context 'with a subgroup with integration' do context 'with a subgroup with integration' do
let(:subgroup) { create(:group, parent: group) } let(:subgroup) { create(:group, parent: group) }
let(:subgroup_integration) { create(:jira_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id) } let(:subgroup_integration) { create(:jira_integration, :group, group: subgroup, inherit_from_id: group_integration.id) }
it 'calls to PropagateIntegrationInheritDescendantWorker' do it 'calls to PropagateIntegrationInheritDescendantWorker' do
expect(PropagateIntegrationInheritDescendantWorker).to receive(:perform_async) expect(PropagateIntegrationInheritDescendantWorker).to receive(:perform_async)
......
...@@ -74,7 +74,7 @@ RSpec.describe BulkCreateIntegrationService do ...@@ -74,7 +74,7 @@ RSpec.describe BulkCreateIntegrationService do
context 'with a project association' do context 'with a project association' do
let!(:project) { create(:project, group: group) } let!(:project) { create(:project, group: group) }
let(:integration) { create(:jira_integration, group: group, project: nil) } let(:integration) { create(:jira_integration, :group, group: group) }
let(:created_integration) { project.jira_integration } let(:created_integration) { project.jira_integration }
let(:batch) { Project.where(id: Project.minimum(:id)..Project.maximum(:id)).without_integration(integration).in_namespace(integration.group.self_and_descendants) } 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(:association) { 'project' }
...@@ -84,7 +84,7 @@ RSpec.describe BulkCreateIntegrationService do ...@@ -84,7 +84,7 @@ RSpec.describe BulkCreateIntegrationService do
it_behaves_like 'updates inherit_from_id' it_behaves_like 'updates inherit_from_id'
context 'with different foreign key of data_fields' do context 'with different foreign key of data_fields' do
let(:integration) { create(:zentao_integration, group: group, project: nil) } let(:integration) { create(:zentao_integration, :group, group: group) }
let(:created_integration) { project.zentao_integration } let(:created_integration) { project.zentao_integration }
it_behaves_like 'creates integration from batch ids' it_behaves_like 'creates integration from batch ids'
...@@ -94,7 +94,7 @@ RSpec.describe BulkCreateIntegrationService do ...@@ -94,7 +94,7 @@ RSpec.describe BulkCreateIntegrationService do
context 'with a group association' do context 'with a group association' do
let!(:subgroup) { create(:group, parent: group) } let!(:subgroup) { create(:group, parent: group) }
let(:integration) { create(:jira_integration, group: group, project: nil, inherit_from_id: instance_integration.id) } let(:integration) { create(:jira_integration, :group, group: group, inherit_from_id: instance_integration.id) }
let(:created_integration) { Integration.find_by(group: subgroup) } let(:created_integration) { Integration.find_by(group: subgroup) }
let(:batch) { Group.where(id: subgroup.id) } let(:batch) { Group.where(id: subgroup.id) }
let(:association) { 'group' } let(:association) { 'group' }
...@@ -104,7 +104,7 @@ RSpec.describe BulkCreateIntegrationService do ...@@ -104,7 +104,7 @@ RSpec.describe BulkCreateIntegrationService do
it_behaves_like 'updates inherit_from_id' it_behaves_like 'updates inherit_from_id'
context 'with different foreign key of data_fields' do context 'with different foreign key of data_fields' do
let(:integration) { create(:zentao_integration, group: group, project: nil, inherit_from_id: instance_integration.id) } let(:integration) { create(:zentao_integration, :group, group: group, inherit_from_id: instance_integration.id) }
it_behaves_like 'creates integration from batch ids' it_behaves_like 'creates integration from batch ids'
it_behaves_like 'updates inherit_from_id' it_behaves_like 'updates inherit_from_id'
......
...@@ -16,32 +16,19 @@ RSpec.describe BulkUpdateIntegrationService do ...@@ -16,32 +16,19 @@ RSpec.describe BulkUpdateIntegrationService do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:group_integration) do let_it_be(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.jira.com') }
Integrations::Jira.create!( let_it_be(:excluded_integration) { create(:jira_integration, :group, group: create(:group), url: 'http://another.jira.com', push_events: false) }
group: group,
url: 'http://group.jira.com'
)
end
let_it_be(:subgroup_integration) do let_it_be(:subgroup_integration) do
Integrations::Jira.create!( create(:jira_integration, :group,
inherit_from_id: group_integration.id,
group: subgroup, group: subgroup,
inherit_from_id: group_integration.id,
url: 'http://subgroup.jira.com', url: 'http://subgroup.jira.com',
push_events: true push_events: true
) )
end end
let_it_be(:excluded_integration) do
Integrations::Jira.create!(
group: create(:group),
url: 'http://another.jira.com',
push_events: false
)
end
let_it_be(:integration) do let_it_be(:integration) do
Integrations::Jira.create!( create(:jira_integration,
project: create(:project, group: subgroup), project: create(:project, group: subgroup),
inherit_from_id: subgroup_integration.id, inherit_from_id: subgroup_integration.id,
url: 'http://project.jira.com', url: 'http://project.jira.com',
...@@ -92,7 +79,7 @@ RSpec.describe BulkUpdateIntegrationService do ...@@ -92,7 +79,7 @@ RSpec.describe BulkUpdateIntegrationService do
context 'with different foreign key of data_fields' do context 'with different foreign key of data_fields' do
let(:integration) { create(:zentao_integration, project: create(:project, group: group)) } let(:integration) { create(:zentao_integration, project: create(:project, group: group)) }
let(:group_integration) do let(:group_integration) do
Integrations::Zentao.create!( create(:zentao_integration, :group,
group: group, group: group,
url: 'https://group.zentao.net', url: 'https://group.zentao.net',
api_token: 'GROUP_TOKEN', api_token: 'GROUP_TOKEN',
......
...@@ -171,7 +171,7 @@ RSpec.describe Groups::CreateService, '#execute' do ...@@ -171,7 +171,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active group-level integration' do context 'with an active group-level integration' do
let(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) } let(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') } let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
let(:group) do let(:group) do
create(:group).tap do |group| create(:group).tap do |group|
group.add_owner(user) group.add_owner(user)
...@@ -186,7 +186,7 @@ RSpec.describe Groups::CreateService, '#execute' do ...@@ -186,7 +186,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active subgroup' do context 'with an active subgroup' do
let(:service) { described_class.new(user, group_params.merge(parent_id: subgroup.id)) } let(:service) { described_class.new(user, group_params.merge(parent_id: subgroup.id)) }
let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') } let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let(:subgroup) do let(:subgroup) do
create(:group, parent: group).tap do |subgroup| create(:group, parent: group).tap do |subgroup|
subgroup.add_owner(user) subgroup.add_owner(user)
......
...@@ -286,7 +286,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do ...@@ -286,7 +286,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
context 'when the group is allowed to be transferred' do context 'when the group is allowed to be transferred' do
let_it_be(:new_parent_group, reload: true) { create(:group, :public) } let_it_be(:new_parent_group, reload: true) { create(:group, :public) }
let_it_be(:new_parent_group_integration) { create(:integrations_slack, group: new_parent_group, project: nil, webhook: 'http://new-group.slack.com') } let_it_be(:new_parent_group_integration) { create(:integrations_slack, :group, group: new_parent_group, webhook: 'http://new-group.slack.com') }
before do before do
allow(PropagateIntegrationWorker).to receive(:perform_async) allow(PropagateIntegrationWorker).to receive(:perform_async)
...@@ -323,7 +323,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do ...@@ -323,7 +323,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
context 'with an inherited integration' do context 'with an inherited integration' do
let_it_be(:instance_integration) { create(:integrations_slack, :instance, webhook: 'http://project.slack.com') } let_it_be(:instance_integration) { create(:integrations_slack, :instance, webhook: 'http://project.slack.com') }
let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) } let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) }
it 'replaces inherited integrations', :aggregate_failures do it 'replaces inherited integrations', :aggregate_failures do
expect(new_created_integration.webhook).to eq(new_parent_group_integration.webhook) expect(new_created_integration.webhook).to eq(new_parent_group_integration.webhook)
...@@ -333,7 +333,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do ...@@ -333,7 +333,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
end end
context 'with a custom integration' do context 'with a custom integration' do
let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') } let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com') }
it 'does not updates the integrations', :aggregate_failures do it 'does not updates the integrations', :aggregate_failures do
expect { transfer_service.execute(new_parent_group) }.not_to change { group_integration.webhook } expect { transfer_service.execute(new_parent_group) }.not_to change { group_integration.webhook }
......
...@@ -666,7 +666,7 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -666,7 +666,7 @@ RSpec.describe Projects::CreateService, '#execute' do
end end
context 'with an active group-level integration' do context 'with an active group-level integration' do
let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') } let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
let!(:group) do let!(:group) do
create(:group).tap do |group| create(:group).tap do |group|
group.add_owner(user) group.add_owner(user)
...@@ -687,7 +687,7 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -687,7 +687,7 @@ RSpec.describe Projects::CreateService, '#execute' do
end end
context 'with an active subgroup' do context 'with an active subgroup' do
let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') } let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let!(:subgroup) do let!(:subgroup) do
create(:group, parent: group).tap do |subgroup| create(:group, parent: group).tap do |subgroup|
subgroup.add_owner(user) subgroup.add_owner(user)
......
...@@ -7,7 +7,7 @@ RSpec.describe Projects::TransferService do ...@@ -7,7 +7,7 @@ RSpec.describe Projects::TransferService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') } let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com') }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) } let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
......
...@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationGroupWorker do ...@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationGroupWorker do
end end
context 'with a group integration' do context 'with a group integration' do
let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) } let_it_be(:integration) { create(:redmine_integration, :group, group: group) }
it 'calls to BulkCreateIntegrationService' do it 'calls to BulkCreateIntegrationService' do
expect(BulkCreateIntegrationService).to receive(:new) expect(BulkCreateIntegrationService).to receive(:new)
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationInheritDescendantWorker do RSpec.describe PropagateIntegrationInheritDescendantWorker do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:group_integration) { create(:redmine_integration, group: group, project: nil) } let_it_be(:group_integration) { create(:redmine_integration, :group, group: group) }
let_it_be(:subgroup_integration) { create(:redmine_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id) } let_it_be(:subgroup_integration) { create(:redmine_integration, :group, group: subgroup, inherit_from_id: group_integration.id) }
it_behaves_like 'an idempotent worker' do it_behaves_like 'an idempotent worker' do
let(:job_args) { [group_integration.id, subgroup_integration.id, subgroup_integration.id] } let(:job_args) { [group_integration.id, subgroup_integration.id, subgroup_integration.id] }
......
...@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationProjectWorker do ...@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationProjectWorker do
end end
context 'with a group integration' do context 'with a group integration' do
let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) } let_it_be(:integration) { create(:redmine_integration, :group, group: group) }
it 'calls to BulkCreateIntegrationService' do it 'calls to BulkCreateIntegrationService' do
expect(BulkCreateIntegrationService).to receive(:new) expect(BulkCreateIntegrationService).to receive(:new)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment