Commit b25c85a1 authored by Alex Kalderimis's avatar Alex Kalderimis

Rename github project integration

Renames project association from github_service to github_integration.
parent 6700c65b
......@@ -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,7 +41,7 @@ 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 :github_integration, class_name: 'Integrations::Github'
has_one :gitlab_slack_application_service, class_name: 'Integrations::GitlabSlackApplication'
has_one :status_page_setting, inverse_of: :project, class_name: 'StatusPage::ProjectSetting'
......@@ -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
......
......@@ -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
......
......@@ -7,7 +7,7 @@ FactoryBot.define do
type { 'GitlabSlackApplicationService' }
end
factory :github_service, class: 'Integrations::Github' do
factory :github_integration, class: 'Integrations::Github' do
project
type { 'GithubService' }
active { 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
......
......@@ -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
......
......@@ -481,7 +481,7 @@ project:
- error_tracking_setting
- metrics_setting
- gitlab_slack_application_service
- github_service
- 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