diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-01-05 09:22:45 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-01-08 10:22:18 +0300 |
commit | acfb8464bef7b43b730ddf433a8223fc240d968a (patch) | |
tree | 5a377e2f938c0544a9211e76d63979e843571775 | |
parent | b8a275d3e46a4204505ed5a4b7a9b3a6d49c9b4f (diff) |
Fix static anylysy
-rw-r--r-- | db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb | 5 | ||||
-rw-r--r-- | spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb | 14 |
2 files changed, 10 insertions, 9 deletions
diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb index f2455a3d8b0..5ea115cea90 100644 --- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb +++ b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb @@ -66,7 +66,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati .where("services.properties LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')") .select('1') ) .order(project_id: :asc) - end + end scope :kubernetes_service_without_template, -> do where(category: 'deployment') @@ -85,9 +85,10 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati unique_iid = 0 # If it's still conflicted, finding an unique environment scope incrementaly - while true + loop do candidate = "migrated#{unique_iid}/*" return candidate if environment_scopes.exclude?(candidate) + unique_iid += 1 end end diff --git a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb index d6643a63f0d..cade4d7df28 100644 --- a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb +++ b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb @@ -19,7 +19,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do end it 'migrates the KubernetesService to Platform::Kubernetes' do - expect{ migrate! }.to change { Clusters::Cluster.count }.by(sample_num) + expect { migrate! }.to change { Clusters::Cluster.count }.by(sample_num) projects.each do |project| project.clusters.last.tap do |cluster| @@ -76,7 +76,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do end it 'migrates the KubernetesService to Platform::Kubernetes without template' do - expect{ migrate! }.to change { Clusters::Cluster.count }.by(sample_num) + expect { migrate! }.to change { Clusters::Cluster.count }.by(sample_num) projects.each do |project| project.clusters.last.tap do |cluster| @@ -104,7 +104,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do end it 'does not migrate the KubernetesService and disables the kubernetes_service' do # Because the corresponding Platform::Kubernetes already exists - expect{ migrate! }.not_to change { Clusters::Cluster.count } + expect { migrate! }.not_to change { Clusters::Cluster.count } kubernetes_service.reload expect(kubernetes_service).not_to be_active @@ -117,7 +117,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do let!(:kubernetes_service) { create(:kubernetes_service, api_url: 'https://debug.kube.com', active: true, project: project) } it 'migrates the KubernetesService to Platform::Kubernetes' do - expect{ migrate! }.to change { Clusters::Cluster.count }.by(1) + expect { migrate! }.to change { Clusters::Cluster.count }.by(1) kubernetes_service.reload project.clusters.last.tap do |cluster| @@ -136,7 +136,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do let!(:kubernetes_service) { create(:kubernetes_service, api_url: 'https://debug.kube.com', active: true, project: project) } it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated - expect{ migrate! }.to change { Clusters::Cluster.count }.by(1) + expect { migrate! }.to change { Clusters::Cluster.count }.by(1) kubernetes_service.reload project.clusters.last.tap do |cluster| @@ -156,7 +156,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do let!(:kubernetes_service) { create(:kubernetes_service, api_url: 'https://debug.kube.com', active: true, project: project) } it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated - expect{ migrate! }.to change { Clusters::Cluster.count }.by(1) + expect { migrate! }.to change { Clusters::Cluster.count }.by(1) kubernetes_service.reload project.clusters.last.tap do |cluster| @@ -173,7 +173,7 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do let!(:project) { create(:project) } it 'does not migrate the KubernetesService' do - expect{ migrate! }.not_to change { Clusters::Cluster.count } + expect { migrate! }.not_to change { Clusters::Cluster.count } end end end |