Commit a7307c8a authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'zj-use-iid-deployment-refs' into 'master'

Use iid deployment refs

This fixes the 404, because `find_by` will return nil instead of throwing an error.

See merge request !7021
parents de12e6f0 55365d36
...@@ -11,7 +11,7 @@ class Deployment < ActiveRecord::Base ...@@ -11,7 +11,7 @@ class Deployment < ActiveRecord::Base
delegate :name, to: :environment, prefix: true delegate :name, to: :environment, prefix: true
after_save :create_ref after_create :create_ref
def commit def commit
project.commit(sha) project.commit(sha)
...@@ -102,6 +102,6 @@ class Deployment < ActiveRecord::Base ...@@ -102,6 +102,6 @@ class Deployment < ActiveRecord::Base
private private
def ref_path def ref_path
File.join(environment.ref_path, 'deployments', id.to_s) File.join(environment.ref_path, 'deployments', iid.to_s)
end end
end end
...@@ -71,8 +71,8 @@ class Environment < ActiveRecord::Base ...@@ -71,8 +71,8 @@ class Environment < ActiveRecord::Base
return nil unless ref return nil unless ref
deployment_id = ref.split('/').last deployment_iid = ref.split('/').last
deployments.find(deployment_id) deployments.find_by(iid: deployment_iid)
end end
def ref_path def ref_path
......
...@@ -913,7 +913,7 @@ describe Projects::MergeRequestsController do ...@@ -913,7 +913,7 @@ describe Projects::MergeRequestsController do
end end
describe 'GET ci_environments_status' do describe 'GET ci_environments_status' do
context 'when the environment is from a forked project' do context 'the environment is from a forked project' do
let!(:forked) { create(:project) } let!(:forked) { create(:project) }
let!(:environment) { create(:environment, project: forked) } let!(:environment) { create(:environment, project: forked) }
let!(:deployment) { create(:deployment, environment: environment, sha: forked.commit.id, ref: 'master') } let!(:deployment) { create(:deployment, environment: environment, sha: forked.commit.id, ref: 'master') }
......
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