This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 84391de8 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Fix unit tests

parent 00769197fdad
......@@ -6,7 +6,7 @@ class Kubernetes < ActiveRecord::Base
include ReactiveCaching
self.table_name = 'cluster_platforms_kubernetes'
self.reactive_cache_key = ->(kubernetes) { [kubernetes.class.model_name.singular, kubernetes.cluster_id] }
self.reactive_cache_key = ->(kubernetes) { [kubernetes.class.model_name.singular, kubernetes.id] }
belongs_to :cluster, inverse_of: :platform_kubernetes, class_name: 'Clusters::Cluster'
......@@ -41,6 +41,8 @@ class Kubernetes < ActiveRecord::Base
delegate :project, to: :cluster, allow_nil: true
delegate :enabled?, to: :cluster, allow_nil: true
alias_method :active?, :enabled?
def actual_namespace
if namespace.present?
namespace
......
......@@ -4,7 +4,7 @@
include KubernetesHelpers
include ReactiveCachingHelpers
let(:project) { build_stubbed(:kubernetes_project) }
let(:project) { create(:kubernetes_project) }
let(:service) { project.deployment_platform }
describe 'Associations' do
......
......@@ -3100,6 +3100,8 @@ def enable_lfs
describe '#deployment_platform' do
subject { project.deployment_platform }
let(:project) { create(:project) }
context 'when user configured kubernetes from Integration > Kubernetes' do
let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
......
......@@ -2,28 +2,27 @@
describe ReactiveCachingWorker do
let(:service) { project.deployment_platform }
subject { described_class.new.perform("KubernetesService", service.id) }
describe '#perform' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it 'calls #exclusively_update_reactive_cache!' do
expect_any_instance_of(KubernetesService).to receive(:exclusively_update_reactive_cache!)
subject
described_class.new.perform("KubernetesService", service.id)
end
end
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
it 'calls #exclusively_update_reactive_cache!' do
expect_any_instance_of(Clusters::Platforms::Kubernetes).to receive(:exclusively_update_reactive_cache!)
described_class.new.perform("Clusters::Platforms::Kubernetes", service.id)
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment