Commit 9e5f825f authored by Fabio Pitino's avatar Fabio Pitino

Remove conflicting ActiveRecord association

Project in EE declared a `sourced_pipelines` association which
overrides the type defined in the Core association. EE association
wrongly assiged a project source type rather than pipeline source.
parent 53343524
......@@ -98,8 +98,6 @@ module EE
has_many :downstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :upstream_project_id, inverse_of: :upstream_project
has_many :downstream_projects, class_name: 'Project', through: :downstream_project_subscriptions, source: :downstream_project, disable_joins: true
has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id
has_many :incident_management_oncall_schedules, class_name: 'IncidentManagement::OncallSchedule', inverse_of: :project
has_many :incident_management_oncall_rotations, class_name: 'IncidentManagement::OncallRotation', through: :incident_management_oncall_schedules, source: :rotations
has_many :incident_management_escalation_policies, class_name: 'IncidentManagement::EscalationPolicy', inverse_of: :project
......
......@@ -14,17 +14,21 @@ RSpec.describe Ci::TriggerDownstreamSubscriptionService do
end
context 'when pipeline project has downstream projects' do
let(:downstream_project) { create(:project, :repository, upstream_projects: [upstream_project]) }
before do
downstream_project = create(:project, :repository, upstream_projects: [upstream_project])
downstream_project.add_developer(pipeline.user)
end
it 'creates a pipeline' do
expect { execute }.to change { ::Ci::Pipeline.count }.from(1).to(2)
end
it 'associates the downstream pipeline with the upstream project' do
expect { execute }.to change { pipeline.project.sourced_pipelines.count }.from(0).to(1)
expect { execute }
.to change { Ci::Sources::Project.count }.from(0).to(1)
.and change { Ci::Pipeline.count }.from(1).to(2)
project_source = Ci::Sources::Project.last
new_pipeline = Ci::Pipeline.last
expect(project_source.pipeline).to eq(new_pipeline)
expect(project_source.source_project_id).to eq(pipeline.project_id)
end
end
......
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