Commit dee5390e authored by Robert Speicher's avatar Robert Speicher

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

Rename project integration associations (EE) [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!64436
parents bb30daee d044b519
......@@ -47,7 +47,7 @@ module Projects
def redirect_to_service_page
redirect_to edit_project_service_path(
project,
project.gitlab_slack_application_service || project.build_gitlab_slack_application_service
project.gitlab_slack_application_integration || project.build_gitlab_slack_application_integration
)
end
......@@ -65,11 +65,11 @@ module Projects
end
def slack_integration
@slack_integration ||= project.gitlab_slack_application_service.slack_integration
@slack_integration ||= project.gitlab_slack_application_integration.slack_integration
end
def service
@service = project.gitlab_slack_application_service
@service = project.gitlab_slack_application_integration
end
def slack_integration_params
......
......@@ -12,6 +12,10 @@ module EE
github
].freeze
EE_RENAMED_TO_INTEGRATION = %w[
github
].to_set.freeze
class_methods do
extend ::Gitlab::Utils::Override
......@@ -21,6 +25,11 @@ module EE
integrations += EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES if ::Gitlab.com?
integrations
end
override :renamed?
def renamed?(name)
EE_RENAMED_TO_INTEGRATION.include?(name) || super
end
end
end
end
......@@ -41,8 +41,8 @@ module EE
has_one :push_rule, ->(project) { project&.feature_available?(:push_rules) ? all : none }, inverse_of: :project
has_one :index_status
has_one :github_service, class_name: 'Integrations::Github'
has_one :gitlab_slack_application_service, class_name: 'Integrations::GitlabSlackApplication'
has_one :github_integration, class_name: 'Integrations::Github'
has_one :gitlab_slack_application_integration, class_name: 'Integrations::GitlabSlackApplication'
has_one :status_page_setting, inverse_of: :project, class_name: 'StatusPage::ProjectSetting'
has_one :compliance_framework_setting, class_name: 'ComplianceManagement::ComplianceFramework::ProjectSettings', inverse_of: :project
......@@ -151,7 +151,7 @@ module EE
scope :with_security_reports_stored, -> { where('EXISTS (?)', ::Vulnerabilities::Finding.scoped_project.select(1)) }
scope :with_security_reports, -> { where('EXISTS (?)', ::Ci::JobArtifact.security_reports.scoped_project.select(1)) }
scope :with_github_service_pipeline_events, -> { joins(:github_service).merge(::Integrations::Github.pipeline_hooks) }
scope :with_github_integration_pipeline_events, -> { joins(:github_integration).merge(::Integrations::Github.pipeline_hooks) }
scope :with_active_prometheus_integration, -> { joins(:prometheus_integration).merge(::Integrations::Prometheus.active) }
scope :with_enabled_incident_sla, -> { joins(:incident_management_setting).where(project_incident_management_settings: { sla_timer: true }) }
scope :mirrored_with_enabled_pipelines, -> do
......
......@@ -15,7 +15,7 @@ module CiCd
private
def github_integration
@github_integration ||= project.build_github_service(github_params)
@github_integration ||= project.build_github_integration(github_params)
end
def github_params
......
......@@ -11,11 +11,11 @@ module Projects
return error("Slack: #{slack_data['error']}") unless slack_data['ok']
unless project.gitlab_slack_application_service
project.create_gitlab_slack_application_service
unless project.gitlab_slack_application_integration
project.create_gitlab_slack_application_integration
end
service = project.gitlab_slack_application_service
service = project.gitlab_slack_application_integration
SlackIntegration.create!(
service_id: service.id,
......@@ -34,17 +34,17 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def make_sure_chat_name_created(slack_data)
service = project.gitlab_slack_application_service
integration = project.gitlab_slack_application_integration
chat_name = ChatName.find_by(
service_id: service.id,
service_id: integration.id,
team_id: slack_data['team_id'],
chat_id: slack_data['user_id']
)
unless chat_name
ChatName.find_or_create_by!(
service_id: service.id,
service_id: integration.id,
team_id: slack_data['team_id'],
team_domain: slack_data['team_name'],
chat_id: slack_data['user_id'],
......
......@@ -348,7 +348,7 @@ module EE
override :usage_activity_by_stage_verify
def usage_activity_by_stage_verify(time_period)
super.merge({
projects_reporting_ci_cd_back_to_github: distinct_count(::Project.with_github_service_pipeline_events.where(time_period), :creator_id)
projects_reporting_ci_cd_back_to_github: distinct_count(::Project.with_github_integration_pipeline_events.where(time_period), :creator_id)
})
end
......
......@@ -15,7 +15,7 @@ RSpec.describe Projects::Settings::SlacksController do
def redirect_url(project)
edit_project_service_path(
project,
project.build_gitlab_slack_application_service
project.build_gitlab_slack_application_integration
)
end
......
# frozen_string_literal: true
FactoryBot.define do
factory :gitlab_slack_application_service, class: 'Integrations::GitlabSlackApplication' do
factory :gitlab_slack_application_integration, class: 'Integrations::GitlabSlackApplication' do
project
active { true }
type { 'GitlabSlackApplicationService' }
end
factory :github_service, class: 'Integrations::Github' do
factory :github_integration, class: 'Integrations::Github' do
project
type { 'GithubService' }
active { true }
......
......@@ -7,6 +7,6 @@ FactoryBot.define do
sequence(:team_name) { |n| "team#{n}" }
sequence(:alias) { |n| "namespace#{n}/project_name#{n}" }
integration factory: :gitlab_slack_application_service
integration factory: :gitlab_slack_application_integration
end
end
......@@ -6,14 +6,14 @@ RSpec.describe 'Slack application' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
let(:service) { create(:gitlab_slack_application_service, project: project) }
let(:slack_application_form_path) { edit_project_service_path(project, service) }
let(:integration) { create(:gitlab_slack_application_integration, project: project) }
let(:slack_application_form_path) { edit_project_service_path(project, integration) }
before do
gitlab_sign_in(user)
project.add_maintainer(user)
create(:slack_integration, integration: service)
create(:slack_integration, integration: integration)
allow(Gitlab).to receive(:com?).and_return(true)
allow(Gitlab::CurrentSettings).to receive(:slack_app_enabled).and_return(true)
......
......@@ -777,7 +777,7 @@ RSpec.describe Gitlab::UsageData do
describe 'usage_activity_by_stage_verify' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
create(:github_service)
create(:github_integration)
end
expect(described_class.usage_activity_by_stage_verify({})).to include(
......
......@@ -54,7 +54,7 @@ RSpec.describe Project do
it { is_expected.to have_many(:vulnerability_historical_statistics).class_name('Vulnerabilities::HistoricalStatistic') }
it { is_expected.to have_many(:vulnerability_remediations).class_name('Vulnerabilities::Remediation') }
it { is_expected.to have_one(:github_service) }
it { is_expected.to have_one(:github_integration) }
it { is_expected.to have_many(:project_aliases) }
it { is_expected.to have_many(:approval_rules) }
......@@ -295,13 +295,15 @@ RSpec.describe Project do
end
end
describe '.with_github_service_pipeline_events' do
describe '.with_github_integration_pipeline_events' do
it 'returns the correct project' do
project_with_github_service_pipeline_events = create(:project, github_service: create(:github_service))
project_without_github_service_pipeline_events = create(:project)
project_with_github_integration_pipeline_events = create(:project, github_integration: create(:github_integration))
project_without_github_integration_pipeline_events = create(:project)
expect(described_class.with_github_service_pipeline_events).to include(project_with_github_service_pipeline_events)
expect(described_class.with_github_service_pipeline_events).not_to include(project_without_github_service_pipeline_events)
expect(described_class.with_github_integration_pipeline_events)
.to include(project_with_github_integration_pipeline_events)
expect(described_class.with_github_integration_pipeline_events)
.not_to include(project_without_github_integration_pipeline_events)
end
end
......@@ -1569,7 +1571,7 @@ RSpec.describe Project do
it 'returns projects where Slack application is disabled' do
project1 = create(:project)
project2 = create(:project)
create(:gitlab_slack_application_service, project: project2)
create(:gitlab_slack_application_integration, project: project2)
projects = described_class.with_slack_application_disabled
......
......@@ -11,7 +11,7 @@ RSpec.describe API::Services do
describe 'Slack application Service' do
before do
project.create_gitlab_slack_application_service
project.create_gitlab_slack_application_integration
stub_application_setting(
slack_app_verification_token: 'token'
......
......@@ -20,7 +20,7 @@ RSpec.describe CiCd::GithubIntegrationSetupService do
end
describe 'sets up GitHub service integration' do
let(:integration) { project.github_service }
let(:integration) { project.github_integration }
specify 'with API token' do
expect(integration.token).to eq api_token
......
......@@ -29,7 +29,7 @@ RSpec.describe CiCd::GithubSetupService do
subject.execute
expect(project.github_service).to be_active
expect(project.github_integration).to be_active
end
end
end
......@@ -14,7 +14,7 @@ RSpec.describe ::Integrations::Test::ProjectService do
context 'without event specified' do
context 'GitHubService' do
let(:integration) { create(:github_service, project: project) }
let(:integration) { create(:github_integration, project: project) }
it_behaves_like 'tests for integration with pipeline data'
end
......
......@@ -17,12 +17,12 @@ RSpec.describe Projects::SlackApplicationInstallService do
end
def expect_slack_integration_is_created(project)
integration = SlackIntegration.find_by(service_id: project.gitlab_slack_application_service.id)
integration = SlackIntegration.find_by(service_id: project.gitlab_slack_application_integration.id)
expect(integration).to be_present
end
def expect_chat_name_is_created(project)
chat_name = ChatName.find_by(service_id: project.gitlab_slack_application_service.id)
chat_name = ChatName.find_by(service_id: project.gitlab_slack_application_integration.id)
expect(chat_name).to be_present
end
......
......@@ -15,7 +15,7 @@ RSpec.describe SlashCommands::GlobalSlackHandler do
end
def enable_slack_application(project)
create(:gitlab_slack_application_service, project: project)
create(:gitlab_slack_application_integration, project: project)
end
def handler(params)
......@@ -39,7 +39,7 @@ RSpec.describe SlashCommands::GlobalSlackHandler do
enable_slack_application(project)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_service)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_integration)
slack_integration.update(alias: project.full_path)
handler_with_valid_token(
......@@ -54,7 +54,7 @@ RSpec.describe SlashCommands::GlobalSlackHandler do
enable_slack_application(project)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_service)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_integration)
handler_with_valid_token(
text: "fake/fake issue new title",
......@@ -68,7 +68,7 @@ RSpec.describe SlashCommands::GlobalSlackHandler do
enable_slack_application(project)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_service)
slack_integration = create(:slack_integration, integration: project.gitlab_slack_application_integration)
slack_integration.update(alias: project.full_path)
handler_with_valid_token(
......
......@@ -480,8 +480,8 @@ project:
- kubernetes_namespaces
- error_tracking_setting
- metrics_setting
- gitlab_slack_application_service
- github_service
- gitlab_slack_application_integration
- github_integration
- protected_environments
- mirror_user
- push_rule
......
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