blob: 3d8685c76194bb31ded05fee169376fe35fa5f24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe MigrateLegacyManagedClustersToUnmanaged 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
|