diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-09 15:11:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-09 15:11:14 +0300 |
commit | 3fd585614449ccab7fdab083f210c09eb16a6ed2 (patch) | |
tree | 225d8bdfcd0bfd5efe0da44348dd97be558be288 /spec/models | |
parent | 8b50d36626f3a71a2d8552a316d700510559b0de (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/clusters/cluster_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/deployment_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 8 |
3 files changed, 15 insertions, 17 deletions
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index d501325dd90..99932dc27d1 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -188,8 +188,15 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching, context 'cluster has multiple successful deployment with environment' do let!(:environment) { create(:environment) } - let!(:deployment) { create(:deployment, :success, cluster: cluster, environment: environment) } - let!(:deployment_2) { create(:deployment, :success, cluster: cluster, environment: environment) } + let!(:deployment) { create(:deployment, :on_cluster, :success, environment: environment) } + let!(:deployment_2) { create(:deployment, :on_cluster, :success, environment: environment) } + + before do + deployment.deployment_cluster.update!(cluster: cluster) + deployment_2.deployment_cluster.update!(cluster: cluster) + deployment.reload + deployment_2.reload + end it { is_expected.to include(cluster) } @@ -200,9 +207,9 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching, context 'cluster has only failed deployment with environment' do let!(:environment) { create(:environment) } - let!(:deployment) { create(:deployment, :failed, cluster: cluster, environment: environment) } + let!(:deployment) { create(:deployment, :failed, :on_cluster, environment: environment) } - it { is_expected.not_to include(cluster) } + it { is_expected.not_to include(deployment.cluster) } end context 'cluster does not have any deployment' do diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 2a7a8d50895..ede96d79656 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -7,7 +7,6 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do it { is_expected.to belong_to(:project).required } it { is_expected.to belong_to(:environment).required } - it { is_expected.to belong_to(:cluster).class_name('Clusters::Cluster') } it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:deployable) } it { is_expected.to have_one(:deployment_cluster) } @@ -18,6 +17,7 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do it { is_expected.to delegate_method(:commit).to(:project) } it { is_expected.to delegate_method(:commit_title).to(:commit).as(:try) } it { is_expected.to delegate_method(:kubernetes_namespace).to(:deployment_cluster).as(:kubernetes_namespace) } + it { is_expected.to delegate_method(:cluster).to(:deployment_cluster) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } @@ -1476,11 +1476,4 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do end end end - - context 'loose foreign key on deployments.cluster_id' do - it_behaves_like 'cleanup by a loose foreign key' do - let!(:parent) { create(:cluster) } - let!(:model) { create(:deployment, cluster: parent) } - end - end end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 061291906a0..7b7b92a0b8d 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -1660,20 +1660,18 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching, feature_categ end context 'environment has a deployment' do - let!(:deployment) { create(:deployment, :success, environment: environment, cluster: cluster) } - context 'with no cluster associated' do - let(:cluster) { nil } + let!(:deployment) { create(:deployment, :success, environment: environment) } it { is_expected.to be_nil } end context 'with a cluster associated' do - let(:cluster) { create(:cluster) } + let!(:deployment) { create(:deployment, :success, :on_cluster, environment: environment) } it 'calls the service finder' do expect(Clusters::KnativeServicesFinder).to receive(:new) - .with(cluster, environment).and_return(:finder) + .with(deployment.cluster, environment).and_return(:finder) is_expected.to eq :finder end |