Commit 398bdce1 authored by Robert Speicher's avatar Robert Speicher

Merge branch '33933-fix-deployment-indicator-date' into 'master'

Fix bug where Service `created_at` time was used instead of deployment time.

Closes #33933

See merge request !12395
parents 831054a7 e00f4870
......@@ -60,7 +60,7 @@ class PrometheusService < MonitoringService
def deployment_metrics(deployment)
metrics = with_reactive_cache(Gitlab::Prometheus::Queries::DeploymentQuery.name, deployment.id, &method(:rename_data_to_metrics))
metrics&.merge(deployment_time: created_at.to_i) || {}
metrics&.merge(deployment_time: deployment.created_at.to_i) || {}
end
def additional_environment_metrics(environment)
......
......@@ -71,7 +71,7 @@ describe PrometheusService, models: true, caching: true do
end
describe '#deployment_metrics' do
let(:deployment) { build_stubbed(:deployment)}
let(:deployment) { build_stubbed(:deployment) }
let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery }
around do |example|
......@@ -80,13 +80,16 @@ describe PrometheusService, models: true, caching: true do
context 'with valid data' do
subject { service.deployment_metrics(deployment) }
let(:fake_deployment_time) { 10 }
before do
stub_reactive_cache(service, prometheus_data, deployment_query, deployment.id)
end
it 'returns reactive data' do
is_expected.to eq(prometheus_metrics_data.merge(deployment_time: deployment.created_at.to_i))
expect(deployment).to receive(:created_at).and_return(fake_deployment_time)
expect(subject).to eq(prometheus_metrics_data.merge(deployment_time: fake_deployment_time))
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