diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-06-21 04:26:19 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-06-21 04:26:19 +0300 |
commit | 148516ba36855095fa995c2d4e8077919cdb6db6 (patch) | |
tree | 1efc18b892d7cbd51bfa11e4e3350e831bb736b4 /spec/migrations | |
parent | 4562ea32dac7b07c285050b404a02e2de1480752 (diff) | |
parent | 8a8ddec661eb7a4bca740285622bb3f8419732fd (diff) |
Merge branch '62772-migrate-managed-clusters-to-unmanaged' into 'master'
Migrate managed clusters that aren't using managed features to unmanaged
Closes #62772
See merge request gitlab-org/gitlab-ce!29251
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/migrate_legacy_managed_clusters_to_unmanaged_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/migrations/migrate_legacy_managed_clusters_to_unmanaged_spec.rb b/spec/migrations/migrate_legacy_managed_clusters_to_unmanaged_spec.rb new file mode 100644 index 00000000000..93426f1f273 --- /dev/null +++ b/spec/migrations/migrate_legacy_managed_clusters_to_unmanaged_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20190606163724_migrate_legacy_managed_clusters_to_unmanaged.rb') + +describe MigrateLegacyManagedClustersToUnmanaged, :migration do + let(:cluster_type) { 'project_type' } + let(:created_at) { 1.hour.ago } + + let!(:cluster) do + table(:clusters).create!( + name: 'cluster', + cluster_type: described_class::Cluster.cluster_types[cluster_type], + managed: true, + created_at: created_at + ) + end + + it 'marks the cluster as unmanaged' do + migrate! + expect(cluster.reload).not_to be_managed + end + + context 'cluster is not project type' do + let(:cluster_type) { 'group_type' } + + it 'does not update the cluster' do + migrate! + expect(cluster.reload).to be_managed + end + end + + context 'cluster has a kubernetes namespace associated' do + before do + table(:clusters_kubernetes_namespaces).create!( + cluster_id: cluster.id, + namespace: 'namespace' + ) + end + + it 'does not update the cluster' do + migrate! + expect(cluster.reload).to be_managed + end + end + + context 'cluster was recently created' do + let(:created_at) { 2.minutes.ago } + + it 'does not update the cluster' do + migrate! + expect(cluster.reload).to be_managed + end + end +end |