Commit 84ff263c authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'remove_pipeline_environments' into 'master'

Remove pipeline.environments association

See merge request gitlab-org/gitlab!79494
parents 31abe9c5 d4d2a1c7
......@@ -73,7 +73,6 @@ module Ci
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
has_many :variables, class_name: 'Ci::PipelineVariable'
has_many :deployments, through: :builds
has_many :environments, -> { distinct.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338658') }, through: :deployments
has_many :latest_builds, -> { latest.with_project_and_metadata }, foreign_key: :commit_id, inverse_of: :pipeline, class_name: 'Ci::Build'
has_many :downloadable_artifacts, -> do
not_expired.or(where_exists(::Ci::Pipeline.artifacts_locked.where('ci_pipelines.id = ci_builds.commit_id'))).downloadable.with_job
......
......@@ -3524,7 +3524,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
let!(:job) { create(:ci_build, :with_deployment, :start_review_app, pipeline: pipeline, project: project) }
it 'returns environments' do
is_expected.to eq(pipeline.environments)
is_expected.to eq(pipeline.environments_in_self_and_descendants.to_a)
expect(subject.count).to be(1)
end
......
......@@ -185,7 +185,7 @@ RSpec.describe Environments::StopService do
end
it 'has active environment at first' do
expect(pipeline.environments.first).to be_available
expect(pipeline.environments_in_self_and_descendants.first).to be_available
end
context 'when user is a developer' do
......@@ -196,7 +196,7 @@ RSpec.describe Environments::StopService do
it 'stops the active environment' do
subject
expect(pipeline.environments.first).to be_stopped
expect(pipeline.environments_in_self_and_descendants.first).to be_stopped
end
end
......@@ -208,7 +208,7 @@ RSpec.describe Environments::StopService do
it 'does not stop the active environment' do
subject
expect(pipeline.environments.first).to be_available
expect(pipeline.environments_in_self_and_descendants.first).to be_available
end
end
......@@ -232,7 +232,7 @@ RSpec.describe Environments::StopService do
it 'does not stop the active environment' do
subject
expect(pipeline.environments.first).to be_available
expect(pipeline.environments_in_self_and_descendants.first).to be_available
end
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