Commit 989ea960 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '330300-ajk-rst' into 'master'

Rename project integration associations: RST [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!64334
parents 3cf48f31 d9e1d0cb
......@@ -51,6 +51,9 @@ class Integration < ApplicationRecord
jenkins jira
packagist pipelines_email pivotaltracker pushover
mattermost mattermost_slash_commands microsoft_teams mock_ci mock_monitoring
redmine
slack slack_slash_commands
teamcity
].to_set.freeze
def self.renamed?(name)
......
......@@ -184,10 +184,10 @@ class Project < ApplicationRecord
has_one :pivotaltracker_integration, class_name: 'Integrations::Pivotaltracker'
has_one :prometheus_service, class_name: 'Integrations::Prometheus', inverse_of: :project
has_one :pushover_integration, class_name: 'Integrations::Pushover'
has_one :redmine_service, class_name: 'Integrations::Redmine'
has_one :slack_service, class_name: 'Integrations::Slack'
has_one :slack_slash_commands_service, class_name: 'Integrations::SlackSlashCommands'
has_one :teamcity_service, class_name: 'Integrations::Teamcity'
has_one :redmine_integration, class_name: 'Integrations::Redmine'
has_one :slack_integration, class_name: 'Integrations::Slack'
has_one :slack_slash_commands_integration, class_name: 'Integrations::SlackSlashCommands'
has_one :teamcity_integration, class_name: 'Integrations::Teamcity'
has_one :unify_circuit_service, class_name: 'Integrations::UnifyCircuit'
has_one :webex_teams_service, class_name: 'Integrations::WebexTeams'
has_one :youtrack_service, class_name: 'Integrations::Youtrack'
......
......@@ -158,8 +158,8 @@ module EE
joins(:project_feature).mirror.where(mirror_trigger_builds: true,
project_features: { builds_access_level: ::ProjectFeature::ENABLED })
end
scope :with_slack_service, -> { joins(:slack_service) }
scope :with_slack_slash_commands_service, -> { joins(:slack_slash_commands_service) }
scope :with_slack_integration, -> { joins(:slack_integration) }
scope :with_slack_slash_commands_integration, -> { joins(:slack_slash_commands_integration) }
scope :with_prometheus_service, -> { joins(:prometheus_service) }
scope :aimed_for_deletion, -> (date) { where('marked_for_deletion_at <= ?', date).without_deleted }
scope :not_aimed_for_deletion, -> { where(marked_for_deletion_at: nil) }
......
......@@ -231,8 +231,8 @@ module EE
override :usage_activity_by_stage_configure
def usage_activity_by_stage_configure(time_period)
super.merge({
projects_slack_notifications_active: distinct_count(::Project.with_slack_service.where(time_period), :creator_id),
projects_slack_slash_active: distinct_count(::Project.with_slack_slash_commands_service.where(time_period), :creator_id)
projects_slack_notifications_active: distinct_count(::Project.with_slack_integration.where(time_period), :creator_id),
projects_slack_slash_active: distinct_count(::Project.with_slack_slash_commands_integration.where(time_period), :creator_id)
})
end
......
......@@ -41,8 +41,8 @@ RSpec.describe EE::ServicesHelper do
assign(:project, project)
end
context 'Slack service' do
let(:integration) { build(:slack_service) }
context 'with Slack integration' do
let(:integration) { build(:integrations_slack) }
it 'does not include Jira specific fields' do
is_expected.not_to include(*jira_fields.keys)
......
......@@ -259,8 +259,8 @@ RSpec.describe Gitlab::UsageData do
for_defined_days_back do
user = create(:user)
project = create(:project, creator: user)
create(:slack_service, project: project)
create(:slack_slash_commands_service, project: project)
create(:integrations_slack, project: project)
create(:slack_slash_commands_integration, project: project)
create(:prometheus_service, project: project)
end
......
......@@ -130,7 +130,9 @@ RSpec.describe Projects::ServicesController do
end
context 'with the Slack integration' do
let_it_be(:service) { build(:slack_service) }
let_it_be(:integration) { build(:integrations_slack) }
let(:service) { integration } # TODO: remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 is complete
it 'returns an error response when the URL is blocked' do
put :test, params: project_params(service: { webhook: 'http://127.0.0.1' })
......
......@@ -91,7 +91,7 @@ FactoryBot.define do
issue_tracker
end
factory :redmine_service, class: 'Integrations::Redmine' do
factory :redmine_integration, class: 'Integrations::Redmine' do
project
active { true }
issue_tracker
......@@ -160,14 +160,15 @@ FactoryBot.define do
password { 'my-secret-password' }
end
factory :slack_service, class: 'Integrations::Slack' do
# avoids conflict with slack_integration factory
factory :integrations_slack, class: 'Integrations::Slack' do
project
active { true }
webhook { 'https://slack.service.url' }
type { 'SlackService' }
end
factory :slack_slash_commands_service, class: 'Integrations::SlackSlashCommands' do
factory :slack_slash_commands_integration, class: 'Integrations::SlackSlashCommands' do
project
active { true }
type { 'SlackSlashCommandsService' }
......
......@@ -396,7 +396,7 @@ FactoryBot.define do
factory :redmine_project, parent: :project do
has_external_issue_tracker { true }
redmine_service
redmine_integration
end
factory :youtrack_project, parent: :project do
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'Admin visits service templates' do
let(:admin) { create(:user, :admin) }
let(:slack_service) { Integration.for_template.find { |s| s.type == 'SlackService' } }
let(:slack_integration) { Integration.for_template.find { |s| s.type == 'SlackService' } }
before do
sign_in(admin)
......@@ -23,7 +23,7 @@ RSpec.describe 'Admin visits service templates' do
context 'with an active service template' do
before do
create(:slack_service, :template, active: true)
create(:integrations_slack, :template, active: true)
visit(admin_application_settings_services_path)
end
......@@ -33,20 +33,20 @@ RSpec.describe 'Admin visits service templates' do
context 'without instance-level integration' do
it 'shows a link to service template' do
expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_integration.id))
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_integration))
end
end
context 'with instance-level integration' do
before do
create(:slack_service, instance: true, project: nil)
create(:integrations_slack, instance: true, project: nil)
visit(admin_application_settings_services_path)
end
it 'shows a link to instance-level integration' do
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_integration.id))
expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_integration))
end
end
end
......
......@@ -20,12 +20,12 @@ RSpec.describe 'User activates Slack notifications', :js do
end
context 'when service is already configured' do
let(:service) { Integrations::Slack.new }
let(:project) { create(:project, slack_service: service) }
let(:integration) { Integrations::Slack.new }
let(:project) { create(:project, slack_integration: integration) }
before do
service.fields
service.update!(
integration.fields
integration.update!(
push_channel: 1,
issue_channel: 2,
merge_request_channel: 3,
......@@ -34,7 +34,7 @@ RSpec.describe 'User activates Slack notifications', :js do
pipeline_channel: 6,
wiki_page_channel: 7)
visit(edit_project_service_path(project, service))
visit(edit_project_service_path(project, integration))
end
it 'filters events by channel' do
......
......@@ -36,8 +36,8 @@ RSpec.describe ServicesHelper do
subject { helper.integration_form_data(integration) }
context 'Slack service' do
let(:integration) { build(:slack_service) }
context 'with Slack integration' do
let(:integration) { build(:integrations_slack) }
it { is_expected.to include(*fields) }
it { is_expected.not_to include(*jira_fields) }
......
......@@ -118,7 +118,7 @@ RSpec.describe Banzai::Filter::References::ExternalIssueReferenceFilter do
end
context "redmine project" do
let_it_be(:service) { create(:redmine_service, project: project) }
let_it_be(:integration) { create(:redmine_integration, project: project) }
before do
project.update!(issues_enabled: false)
......
......@@ -369,7 +369,7 @@ project:
- emails_on_push_integration
- pipelines_email_integration
- mattermost_slash_commands_integration
- slack_slash_commands_service
- slack_slash_commands_integration
- irker_integration
- packagist_integration
- pivotaltracker_integration
......@@ -377,17 +377,17 @@ project:
- flowdock_integration
- assembla_integration
- asana_integration
- slack_service
- slack_integration
- microsoft_teams_integration
- mattermost_integration
- hangouts_chat_integration
- unify_circuit_service
- buildkite_integration
- bamboo_integration
- teamcity_service
- teamcity_integration
- pushover_integration
- jira_integration
- redmine_service
- redmine_integration
- youtrack_service
- custom_issue_tracker_integration
- bugzilla_integration
......
......@@ -14,7 +14,7 @@ RSpec.describe HasIntegrations do
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, project: project_3, inherit_from_id: nil)
create(:slack_service, project: project_4, inherit_from_id: nil)
create(:integrations_slack, project: project_4, inherit_from_id: nil)
end
describe '.with_custom_integration_for' do
......
......@@ -569,7 +569,7 @@ RSpec.describe Group do
before do
create(:jira_integration, group: group, project: nil)
create(:slack_service, group: another_group, project: nil)
create(:integrations_slack, group: another_group, project: nil)
end
it 'returns groups without integration' do
......
......@@ -70,7 +70,7 @@ RSpec.describe Integration do
describe '.by_type' do
let!(:service1) { create(:jira_integration) }
let!(:service2) { create(:jira_integration) }
let!(:service3) { create(:redmine_service) }
let!(:service3) { create(:redmine_integration) }
subject { described_class.by_type(type) }
......
......@@ -19,7 +19,7 @@ RSpec.describe Integrations::SlackSlashCommands do
end
let(:service) do
project.create_slack_slash_commands_service(
project.create_slack_slash_commands_integration(
properties: { token: 'token' },
active: true
)
......
......@@ -10,7 +10,7 @@ RSpec.describe Integrations::Slack do
stub_request(:post, "https://slack.service.url/")
end
let_it_be(:slack_service) { create(:slack_service, branches_to_be_notified: 'all') }
let_it_be(:slack_integration) { create(:integrations_slack, branches_to_be_notified: 'all') }
it 'uses only known events', :aggregate_failures do
described_class::SUPPORTED_EVENTS_FOR_USAGE_LOG.each do |action|
......@@ -26,7 +26,7 @@ RSpec.describe Integrations::Slack do
it 'increases the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: user.id).and_call_original
slack_service.execute(data)
slack_integration.execute(data)
end
end
......@@ -38,7 +38,7 @@ RSpec.describe Integrations::Slack do
it 'does not increase the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with('i_ecosystem_slack_service_pipeline_notification', values: user.id)
slack_service.execute(data)
slack_integration.execute(data)
end
end
......@@ -126,7 +126,7 @@ RSpec.describe Integrations::Slack do
it 'does not increase the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
slack_service.execute(data)
slack_integration.execute(data)
end
end
end
......
......@@ -10,7 +10,7 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
let(:teamcity_full_url) { 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123' }
let(:project) { create(:project) }
subject(:service) do
subject(:integration) do
described_class.create!(
project: project,
properties: {
......@@ -28,14 +28,14 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:build_type) }
it { is_expected.to validate_presence_of(:teamcity_url) }
it_behaves_like 'issue tracker service URL attribute', :teamcity_url
it_behaves_like 'issue tracker integration URL attribute', :teamcity_url
describe '#username' do
it 'does not validate the presence of username if password is nil' do
......@@ -66,7 +66,7 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
end
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......@@ -79,71 +79,66 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
end
describe 'Callbacks' do
let(:teamcity_integration) { integration }
describe 'before_update :reset_password' do
context 'when a password was previously set' do
it 'resets password if url changed' do
teamcity_service = service
teamcity_service.teamcity_url = 'http://gitlab1.com'
teamcity_service.save!
teamcity_integration.teamcity_url = 'http://gitlab1.com'
teamcity_integration.save!
expect(teamcity_service.password).to be_nil
expect(teamcity_integration.password).to be_nil
end
it 'does not reset password if username changed' do
teamcity_service = service
teamcity_integration.username = 'some_name'
teamcity_integration.save!
teamcity_service.username = 'some_name'
teamcity_service.save!
expect(teamcity_service.password).to eq('password')
expect(teamcity_integration.password).to eq('password')
end
it "does not reset password if new url is set together with password, even if it's the same password" do
teamcity_service = service
teamcity_service.teamcity_url = 'http://gitlab_edited.com'
teamcity_service.password = 'password'
teamcity_service.save!
teamcity_integration.teamcity_url = 'http://gitlab_edited.com'
teamcity_integration.password = 'password'
teamcity_integration.save!
expect(teamcity_service.password).to eq('password')
expect(teamcity_service.teamcity_url).to eq('http://gitlab_edited.com')
expect(teamcity_integration.password).to eq('password')
expect(teamcity_integration.teamcity_url).to eq('http://gitlab_edited.com')
end
end
it 'saves password if new url is set together with password when no password was previously set' do
teamcity_service = service
teamcity_service.password = nil
teamcity_integration.password = nil
teamcity_service.teamcity_url = 'http://gitlab_edited.com'
teamcity_service.password = 'password'
teamcity_service.save!
teamcity_integration.teamcity_url = 'http://gitlab_edited.com'
teamcity_integration.password = 'password'
teamcity_integration.save!
expect(teamcity_service.password).to eq('password')
expect(teamcity_service.teamcity_url).to eq('http://gitlab_edited.com')
expect(teamcity_integration.password).to eq('password')
expect(teamcity_integration.teamcity_url).to eq('http://gitlab_edited.com')
end
end
end
describe '#build_page' do
it 'returns the contents of the reactive cache' do
stub_reactive_cache(service, { build_page: 'foo' }, 'sha', 'ref')
stub_reactive_cache(integration, { build_page: 'foo' }, 'sha', 'ref')
expect(service.build_page('sha', 'ref')).to eq('foo')
expect(integration.build_page('sha', 'ref')).to eq('foo')
end
end
describe '#commit_status' do
it 'returns the contents of the reactive cache' do
stub_reactive_cache(service, { commit_status: 'foo' }, 'sha', 'ref')
stub_reactive_cache(integration, { commit_status: 'foo' }, 'sha', 'ref')
expect(service.commit_status('sha', 'ref')).to eq('foo')
expect(integration.commit_status('sha', 'ref')).to eq('foo')
end
end
describe '#calculate_reactive_cache' do
context 'build_page' do
subject { service.calculate_reactive_cache('123', 'unused')[:build_page] }
subject { integration.calculate_reactive_cache('123', 'unused')[:build_page] }
it 'returns a specific URL when status is 500' do
stub_request(status: 500)
......@@ -179,7 +174,7 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
end
context 'commit_status' do
subject { service.calculate_reactive_cache('123', 'unused')[:commit_status] }
subject { integration.calculate_reactive_cache('123', 'unused')[:commit_status] }
it 'sets commit status to :error when status is 500' do
stub_request(status: 500)
......@@ -243,25 +238,25 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
it 'handles push request correctly' do
stub_post_to_build_queue(branch: 'dev-123_branch')
expect(service.execute(data)).to include('Ok')
expect(integration.execute(data)).to include('Ok')
end
it 'returns nil when ref is blank' do
data[:after] = Gitlab::Git::BLANK_SHA
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
it 'returns nil when there is no content' do
data[:total_commits_count] = 0
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
it 'returns nil when a merge request is opened for the same ref' do
create(:merge_request, source_project: project, source_branch: 'dev-123_branch')
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
end
......@@ -283,26 +278,26 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do
it 'handles merge request correctly' do
stub_post_to_build_queue(branch: 'dev-123_branch')
expect(service.execute(data)).to include('Ok')
expect(integration.execute(data)).to include('Ok')
end
it 'returns nil when merge request is not opened' do
data[:object_attributes][:state] = 'closed'
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
it 'returns nil unless merge request is marked as unchecked' do
data[:object_attributes][:merge_status] = 'can_be_merged'
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
end
it 'returns nil when event is not supported' do
data = { object_kind: 'foo' }
expect(service.execute(data)).to be_nil
expect(integration.execute(data)).to be_nil
end
end
......
......@@ -35,7 +35,7 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to have_many(:hooks) }
it { is_expected.to have_many(:protected_branches) }
it { is_expected.to have_many(:exported_protected_branches) }
it { is_expected.to have_one(:slack_service) }
it { is_expected.to have_one(:slack_integration) }
it { is_expected.to have_one(:microsoft_teams_integration) }
it { is_expected.to have_one(:mattermost_integration) }
it { is_expected.to have_one(:hangouts_chat_integration) }
......@@ -55,13 +55,13 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to have_one(:pivotaltracker_integration) }
it { is_expected.to have_one(:flowdock_integration) }
it { is_expected.to have_one(:assembla_integration) }
it { is_expected.to have_one(:slack_slash_commands_service) }
it { is_expected.to have_one(:slack_slash_commands_integration) }
it { is_expected.to have_one(:mattermost_slash_commands_integration) }
it { is_expected.to have_one(:buildkite_integration) }
it { is_expected.to have_one(:bamboo_integration) }
it { is_expected.to have_one(:teamcity_service) }
it { is_expected.to have_one(:teamcity_integration) }
it { is_expected.to have_one(:jira_integration) }
it { is_expected.to have_one(:redmine_service) }
it { is_expected.to have_one(:redmine_integration) }
it { is_expected.to have_one(:youtrack_service) }
it { is_expected.to have_one(:custom_issue_tracker_integration) }
it { is_expected.to have_one(:bugzilla_integration) }
......@@ -5369,26 +5369,26 @@ RSpec.describe Project, factory_default: :keep do
end
describe '#execute_services' do
let(:service) { create(:slack_service, push_events: true, merge_requests_events: false, active: true) }
let(:integration) { create(:integrations_slack, push_events: true, merge_requests_events: false, active: true) }
it 'executes services with the specified scope' do
it 'executes integrations with the specified scope' do
data = 'any data'
expect_next_found_instance_of(Integrations::Slack) do |instance|
expect(instance).to receive(:async_execute).with(data).once
end
service.project.execute_services(data, :push_hooks)
integration.project.execute_services(data, :push_hooks)
end
it 'does not execute services that don\'t match the specified scope' do
it 'does not execute integration that don\'t match the specified scope' do
expect(Integrations::Slack).not_to receive(:allocate).and_wrap_original do |method|
method.call.tap do |instance|
expect(instance).not_to receive(:async_execute)
end
end
service.project.execute_services(anything, :merge_request_hooks)
integration.project.execute_services(anything, :merge_request_hooks)
end
end
......
......@@ -9,7 +9,7 @@ RSpec.describe 'query Jira service' do
let_it_be(:project) { create(:project) }
let_it_be(:jira_integration) { create(:jira_integration, project: project) }
let_it_be(:bugzilla_integration) { create(:bugzilla_integration, project: project) }
let_it_be(:redmine_service) { create(:redmine_service, project: project) }
let_it_be(:redmine_integration) { create(:redmine_integration, project: project) }
let(:query) do
%(
......
......@@ -239,7 +239,7 @@ RSpec.describe API::Services do
let(:service_name) { 'slack_slash_commands' }
before do
project.create_slack_slash_commands_service(
project.create_slack_slash_commands_integration(
active: true,
properties: { token: 'token' }
)
......
......@@ -12,7 +12,7 @@ RSpec.describe ServiceEventEntity do
end
describe '#as_json' do
context 'service without fields' do
context 'integration without fields' do
let(:integration) { create(:emails_on_push_integration, push_events: true) }
let(:event) { 'push' }
......@@ -24,8 +24,8 @@ RSpec.describe ServiceEventEntity do
end
end
context 'service with fields' do
let(:integration) { create(:slack_service, note_events: false, note_channel: 'note-channel') }
context 'integration with fields' do
let(:integration) { create(:integrations_slack, note_events: false, note_channel: 'note-channel') }
let(:event) { 'note' }
it 'exposes correct attributes' do
......
......@@ -20,7 +20,7 @@ RSpec.describe Admin::PropagateIntegrationService do
end
let_it_be(:different_type_inherited_integration) do
create(:redmine_service, project: project, inherit_from_id: instance_integration.id)
create(:redmine_integration, project: project, inherit_from_id: instance_integration.id)
end
context 'with inherited integration' do
......
......@@ -241,7 +241,7 @@ RSpec.describe Groups::TransferService 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_integration) { create(:slack_service, group: new_parent_group, project: nil, webhook: 'http://new-group.slack.com') }
let_it_be(:new_parent_group_integration) { create(:integrations_slack, group: new_parent_group, project: nil, webhook: 'http://new-group.slack.com') }
before do
allow(PropagateIntegrationWorker).to receive(:perform_async)
......@@ -277,8 +277,8 @@ RSpec.describe Groups::TransferService do
let(:new_created_integration) { Integration.find_by(group: group) }
context 'with an inherited integration' do
let_it_be(:instance_integration) { create(:slack_service, :instance, webhook: 'http://project.slack.com') }
let_it_be(:group_integration) { create(:slack_service, group: group, project: nil, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) }
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) }
it 'replaces inherited integrations', :aggregate_failures do
expect(new_created_integration.webhook).to eq(new_parent_group_integration.webhook)
......@@ -288,7 +288,7 @@ RSpec.describe Groups::TransferService do
end
context 'with a custom integration' do
let_it_be(:group_integration) { create(:slack_service, group: group, project: nil, webhook: 'http://group.slack.com') }
let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') }
it 'does not updates the integrations', :aggregate_failures do
expect { transfer_service.execute(new_parent_group) }.not_to change { group_integration.webhook }
......
......@@ -7,7 +7,8 @@ RSpec.describe Integrations::Test::ProjectService do
describe '#execute' do
let_it_be(:project) { create(:project) }
let(:integration) { create(:slack_service, project: project) }
let(:integration) { create(:integrations_slack, project: project) }
let(:user) { project.owner }
let(:event) { nil }
let(:sample_data) { { data: 'sample' } }
......
......@@ -7,7 +7,7 @@ RSpec.describe Projects::TransferService do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:group_integration) { create(:slack_service, group: group, project: nil, webhook: 'http://group.slack.com') }
let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
subject(:execute_transfer) { described_class.new(project, user).execute(group).tap { project.reload } }
......@@ -121,24 +121,24 @@ RSpec.describe Projects::TransferService do
context 'with a project integration' do
let_it_be_with_reload(:project) { create(:project, namespace: user.namespace) }
let_it_be(:instance_integration) { create(:slack_service, :instance, webhook: 'http://project.slack.com') }
let_it_be(:instance_integration) { create(:integrations_slack, :instance, webhook: 'http://project.slack.com') }
context 'with an inherited integration' do
let_it_be(:project_integration) { create(:slack_service, project: project, webhook: 'http://project.slack.com', inherit_from_id: instance_integration.id) }
let_it_be(:project_integration) { create(:integrations_slack, project: project, webhook: 'http://project.slack.com', inherit_from_id: instance_integration.id) }
it 'replaces inherited integrations', :aggregate_failures do
execute_transfer
expect(project.slack_service.webhook).to eq(group_integration.webhook)
expect(project.slack_integration.webhook).to eq(group_integration.webhook)
expect(Integration.count).to eq(3)
end
end
context 'with a custom integration' do
let_it_be(:project_integration) { create(:slack_service, project: project, webhook: 'http://project.slack.com') }
let_it_be(:project_integration) { create(:integrations_slack, project: project, webhook: 'http://project.slack.com') }
it 'does not updates the integrations' do
expect { execute_transfer }.not_to change { project.slack_service.webhook }
expect { execute_transfer }.not_to change { project.slack_integration.webhook }
end
end
end
......
......@@ -8,7 +8,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
def execute_with_options(options)
receive(:new).with(webhook_url, options.merge(http_client: Integrations::SlackMattermostNotifier::HTTPClient))
.and_return(double(:slack_service).as_null_object)
.and_return(double(:slack_integration).as_null_object)
end
describe "Associations" do
......
# frozen_string_literal: true
RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr|
RSpec.shared_examples 'issue tracker integration URL attribute' do |url_attr|
it { is_expected.to allow_value('https://example.com').for(url_attr) }
it { is_expected.not_to allow_value('example.com').for(url_attr) }
......@@ -8,6 +8,12 @@ RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr|
it { is_expected.not_to allow_value('herp-and-derp').for(url_attr) }
end
# TODO: clean up:
# remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 has been completed
RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr|
it_behaves_like 'issue tracker integration URL attribute', url_attr
end
RSpec.shared_examples 'allows project key on reference pattern' do |url_attr|
it 'allows underscores in the project name' do
expect(described_class.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234'
......
......@@ -15,7 +15,7 @@ RSpec.describe 'projects/services/_form' do
current_user: user,
can?: true,
current_application_settings: Gitlab::CurrentSettings.current_application_settings,
integration: project.redmine_service,
integration: project.redmine_integration,
request: double(referer: '/services')
)
end
......
......@@ -8,7 +8,7 @@ RSpec.describe PropagateIntegrationGroupWorker do
let_it_be(:another_group) { create(:group) }
let_it_be(:subgroup1) { create(:group, parent: group) }
let_it_be(:subgroup2) { create(:group, parent: group) }
let_it_be(:integration) { create(:redmine_service, :instance) }
let_it_be(:integration) { create(:redmine_integration, :instance) }
let(:job_args) { [integration.id, group.id, subgroup2.id] }
......@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationGroupWorker do
end
context 'with a group integration' do
let_it_be(:integration) { create(:redmine_service, group: group, project: nil) }
let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) }
it 'calls to BulkCreateIntegrationService' do
expect(BulkCreateIntegrationService).to receive(:new)
......
......@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationInheritDescendantWorker do
let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:group_integration) { create(:redmine_service, group: group, project: nil) }
let_it_be(:subgroup_integration) { create(:redmine_service, group: subgroup, project: nil, inherit_from_id: group_integration.id) }
let_it_be(:group_integration) { create(:redmine_integration, group: group, project: nil) }
let_it_be(:subgroup_integration) { create(:redmine_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id) }
it_behaves_like 'an idempotent worker' do
let(:job_args) { [group_integration.id, subgroup_integration.id, subgroup_integration.id] }
......
......@@ -4,10 +4,10 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationInheritWorker do
describe '#perform' do
let_it_be(:integration) { create(:redmine_service, :instance) }
let_it_be(:integration1) { create(:redmine_service, inherit_from_id: integration.id) }
let_it_be(:integration) { create(:redmine_integration, :instance) }
let_it_be(:integration1) { create(:redmine_integration, inherit_from_id: integration.id) }
let_it_be(:integration2) { create(:bugzilla_integration, inherit_from_id: integration.id) }
let_it_be(:integration3) { create(:redmine_service) }
let_it_be(:integration3) { create(:redmine_integration) }
it_behaves_like 'an idempotent worker' do
let(:job_args) { [integration.id, integration1.id, integration3.id] }
......
......@@ -8,7 +8,7 @@ RSpec.describe PropagateIntegrationProjectWorker do
let_it_be(:project1) { create(:project) }
let_it_be(:project2) { create(:project, group: group) }
let_it_be(:project3) { create(:project, group: group) }
let_it_be(:integration) { create(:redmine_service, :instance) }
let_it_be(:integration) { create(:redmine_integration, :instance) }
let(:job_args) { [integration.id, project1.id, project3.id] }
......@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationProjectWorker do
end
context 'with a group integration' do
let_it_be(:integration) { create(:redmine_service, group: group, project: nil) }
let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) }
it 'calls to BulkCreateIntegrationService' do
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