Commit f567f75f authored by Kamil Trzciński's avatar Kamil Trzciński Committed by Rémy Coutable

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
parent e59383af
......@@ -11,7 +11,7 @@ class Deployment < ActiveRecord::Base
delegate :name, to: :environment, prefix: true
after_save :create_ref
after_create :create_ref
def commit
project.commit(sha)
......@@ -102,6 +102,6 @@ class Deployment < ActiveRecord::Base
private
def ref_path
File.join(environment.ref_path, 'deployments', id.to_s)
File.join(environment.ref_path, 'deployments', iid.to_s)
end
end
......@@ -71,8 +71,8 @@ class Environment < ActiveRecord::Base
return nil unless ref
deployment_id = ref.split('/').last
deployments.find(deployment_id)
deployment_iid = ref.split('/').last
deployments.find_by(iid: deployment_iid)
end
def ref_path
......
......@@ -913,7 +913,7 @@ describe Projects::MergeRequestsController do
end
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!(:environment) { create(:environment, project: forked) }
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