summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-01-06 00:37:40 +0900
committerShinya Maeda <shinya@gitlab.com>2018-01-08 16:22:18 +0900
commit1c404c91b6e0bb0fac335083eff2f286d0da6df1 (patch)
tree5d9a28811964253dfcebc5037fa575a7e7c0d56c
parent2d3c7d29b2950110f51cde9b6c8c39f9d7404884 (diff)
downloadgitlab-ce-1c404c91b6e0bb0fac335083eff2f286d0da6df1.tar.gz
Add a new test for emptified params
-rw-r--r--spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb21
1 files changed, 19 insertions, 2 deletions
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 cade4d7df28..5f135ad274e 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
@@ -42,8 +42,8 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
context 'when KubernetesService is not active' do
let(:active) { false }
- # Platforms::Kubernetes validates `token` reagdless of the activeness
- # KubernetesService validates `token` if only it's activated
+ # Platforms::Kubernetes validates `token` reagdless of the activeness,
+ # whereas KubernetesService validates `token` if only it's activated
# However, in this migration file, there are no validations because of the migration specific model class
# therefore, Validation Error will not happen in this case and just migrate data
let(:token) { '' }
@@ -169,6 +169,23 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
+ context 'when KubernetesService has nullified parameters' do
+ let(:project) { create(:project) }
+
+ before do
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO services (project_id, active, category, type, properties)
+ VALUES (#{project.id}, false, 'deployment', 'KubernetesService', '{}');
+ SQL
+ end
+
+ it 'does not migrate the KubernetesService and disables the kubernetes_service' do
+ expect { migrate! }.not_to change { Clusters::Cluster.count }
+
+ expect(project.kubernetes_service).not_to be_active
+ end
+ end
+
context 'when KubernetesService does not exist' do
let!(:project) { create(:project) }