diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-06-24 11:33:32 +1200 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-06-27 17:28:52 +1200 |
commit | 2f96e5d3b9e750c5faef1fc8d95b18cb02002516 (patch) | |
tree | f86f14017eb18b5a3b11945a423772c98ea2228b | |
parent | 525edec78bc39ae41284927f1866def56d21a12a (diff) | |
download | gitlab-ce-2f96e5d3b9e750c5faef1fc8d95b18cb02002516.tar.gz |
Populate cluster_id when creating a deployment
-rw-r--r-- | app/models/concerns/deployable.rb | 1 | ||||
-rw-r--r-- | changelogs/unreleased/add-clusters-to-deployment.yml | 5 | ||||
-rw-r--r-- | spec/models/concerns/deployable_spec.rb | 14 |
3 files changed, 16 insertions, 4 deletions
diff --git a/app/models/concerns/deployable.rb b/app/models/concerns/deployable.rb index bc12b06b5af..957b72f3721 100644 --- a/app/models/concerns/deployable.rb +++ b/app/models/concerns/deployable.rb @@ -18,6 +18,7 @@ module Deployable return unless environment.persisted? create_deployment!( + cluster_id: environment.deployment_platform&.cluster_id, project_id: environment.project_id, environment: environment, ref: ref, diff --git a/changelogs/unreleased/add-clusters-to-deployment.yml b/changelogs/unreleased/add-clusters-to-deployment.yml new file mode 100644 index 00000000000..c85bd3635cc --- /dev/null +++ b/changelogs/unreleased/add-clusters-to-deployment.yml @@ -0,0 +1,5 @@ +--- +title: Persist the cluster a deployment was deployed to +merge_request: 29960 +author: +type: fixed diff --git a/spec/models/concerns/deployable_spec.rb b/spec/models/concerns/deployable_spec.rb index 42bed9434f5..bb73dd8ade0 100644 --- a/spec/models/concerns/deployable_spec.rb +++ b/spec/models/concerns/deployable_spec.rb @@ -7,10 +7,6 @@ describe Deployable do let(:deployment) { job.deployment } let(:environment) { deployment&.environment } - before do - job.reload - end - context 'when the deployable object will deploy to production' do let!(:job) { create(:ci_build, :start_review_app) } @@ -26,6 +22,16 @@ describe Deployable do end end + context 'when the deployable object will deploy to a cluster' do + let(:project) { create(:project) } + let!(:cluster) { create(:cluster, :provided_by_user, projects: [project]) } + let!(:job) { create(:ci_build, :start_review_app, project: project) } + + it 'creates a deployment with cluster association' do + expect(deployment.cluster).to eq(cluster) + end + end + context 'when the deployable object will stop an environment' do let!(:job) { create(:ci_build, :stop_review_app) } |