Commit be3938ee authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fix_logic_for_ingress_can_uninstall' into 'master'

Fix logic for ingress can_uninstall?

See merge request gitlab-org/gitlab!27729
parents 438e0332 55726ec5
...@@ -50,7 +50,7 @@ module Clusters ...@@ -50,7 +50,7 @@ module Clusters
end end
def allowed_to_uninstall? def allowed_to_uninstall?
external_ip_or_hostname? && application_jupyter_nil_or_installable? external_ip_or_hostname? && !application_jupyter_installed?
end end
def install_command def install_command
...@@ -161,8 +161,8 @@ module Clusters ...@@ -161,8 +161,8 @@ module Clusters
YAML.load_file(chart_values_file).deep_merge!(specification) YAML.load_file(chart_values_file).deep_merge!(specification)
end end
def application_jupyter_nil_or_installable? def application_jupyter_installed?
cluster.application_jupyter.nil? || cluster.application_jupyter&.installable? cluster.application_jupyter&.installed?
end end
def modsecurity_snippet_content def modsecurity_snippet_content
......
---
title: Fix logic for ingress can_uninstall?
merge_request: 27729
author:
type: fixed
...@@ -21,26 +21,60 @@ describe Clusters::Applications::Ingress do ...@@ -21,26 +21,60 @@ describe Clusters::Applications::Ingress do
describe '#can_uninstall?' do describe '#can_uninstall?' do
subject { ingress.can_uninstall? } subject { ingress.can_uninstall? }
it 'returns true if external ip is set and no application exists' do context 'with jupyter installed' do
ingress.external_ip = 'IP' before do
create(:clusters_applications_jupyter, :installed, cluster: ingress.cluster)
end
is_expected.to be_truthy it 'returns false if external_ip_or_hostname? is true' do
end ingress.external_ip = 'IP'
it 'returns false if application_jupyter_nil_or_installable? is false' do is_expected.to be_falsey
create(:clusters_applications_jupyter, :installed, cluster: ingress.cluster) end
is_expected.to be_falsey it 'returns false if external_ip_or_hostname? is false' do
is_expected.to be_falsey
end
end end
it 'returns false if application_elastic_stack_nil_or_installable? is false' do context 'with jupyter installable' do
create(:clusters_applications_elastic_stack, :installed, cluster: ingress.cluster) before do
create(:clusters_applications_jupyter, :installable, cluster: ingress.cluster)
end
it 'returns true if external_ip_or_hostname? is true' do
ingress.external_ip = 'IP'
is_expected.to be_truthy
end
is_expected.to be_falsey it 'returns false if external_ip_or_hostname? is false' do
is_expected.to be_falsey
end
end end
it 'returns false if external_ip_or_hostname? is false' do context 'with jupyter nil' do
is_expected.to be_falsey it 'returns false if external_ip_or_hostname? is false' do
is_expected.to be_falsey
end
context 'if external_ip_or_hostname? is true' do
context 'with IP' do
before do
ingress.external_ip = 'IP'
end
it { is_expected.to be_truthy }
end
context 'with hostname' do
before do
ingress.external_hostname = 'example.com'
end
it { is_expected.to be_truthy }
end
end
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