Commit ae5bfd89 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '25153-ci_environment_status-endpoint-could-return-a-wrong-deployment' into 'master'

Resolve "`ci_environment_status` return correct deployment"

See merge request gitlab-org/gitlab!83199
parents 98da9924 ce47e982
...@@ -51,7 +51,7 @@ class EnvironmentStatus ...@@ -51,7 +51,7 @@ class EnvironmentStatus
def deployment def deployment
strong_memoize(:deployment) do strong_memoize(:deployment) do
Deployment.where(environment: environment).find_by_sha(sha) Deployment.where(environment: environment).ordered.find_by_sha(sha)
end end
end end
......
...@@ -34,6 +34,13 @@ RSpec.describe EnvironmentStatus do ...@@ -34,6 +34,13 @@ RSpec.describe EnvironmentStatus do
subject { environment_status.deployment } subject { environment_status.deployment }
it { is_expected.to eq(deployment) } it { is_expected.to eq(deployment) }
context 'multiple deployments' do
it {
new_deployment = create(:deployment, :succeed, environment: deployment.environment, sha: deployment.sha )
is_expected.to eq(new_deployment)
}
end
end end
# $ git diff --stat pages-deploy-target...pages-deploy # $ git diff --stat pages-deploy-target...pages-deploy
......
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