Fix environment deployment platform filter method
This commit is contained in:
parent
2faf991f31
commit
8fc9ff7f13
3 changed files with 28 additions and 2 deletions
|
@ -224,7 +224,7 @@ class Environment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def deployment_platform
|
||||
project.deployment_platform(environment: self)
|
||||
project.deployment_platform(environment: self.name)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -79,7 +79,7 @@ module Gitlab
|
|||
def common_query_context(environment, timeframe_start:, timeframe_end:)
|
||||
base_query_context(timeframe_start, timeframe_end).merge({
|
||||
ci_environment_slug: environment.slug,
|
||||
kube_namespace: environment.project.deployment_platform&.actual_namespace || '',
|
||||
kube_namespace: environment.deployment_platform&.actual_namespace || '',
|
||||
environment_filter: %{container_name!="POD",environment="#{environment.slug}"}
|
||||
})
|
||||
end
|
||||
|
|
|
@ -368,6 +368,32 @@ describe Environment do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#deployment_platform' do
|
||||
context 'when there is a deployment platform for environment' do
|
||||
let!(:cluster) do
|
||||
create(:cluster, :provided_by_gcp,
|
||||
environment_scope: '*', projects: [project])
|
||||
end
|
||||
|
||||
it 'finds a deployment platform' do
|
||||
expect(environment.deployment_platform).to eq cluster.platform
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is no deployment platform for environment' do
|
||||
it 'returns nil' do
|
||||
expect(environment.deployment_platform).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
it 'checks deployment platforms associated with a project' do
|
||||
expect(project).to receive(:deployment_platform)
|
||||
.with(environment: environment.name)
|
||||
|
||||
environment.deployment_platform
|
||||
end
|
||||
end
|
||||
|
||||
describe '#terminals' do
|
||||
subject { environment.terminals }
|
||||
|
||||
|
|
Loading…
Reference in a new issue