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
end
def allowed_to_uninstall?
external_ip_or_hostname? && application_jupyter_nil_or_installable?
external_ip_or_hostname? && !application_jupyter_installed?
end
def install_command
......@@ -161,8 +161,8 @@ module Clusters
YAML.load_file(chart_values_file).deep_merge!(specification)
end
def application_jupyter_nil_or_installable?
cluster.application_jupyter.nil? || cluster.application_jupyter&.installable?
def application_jupyter_installed?
cluster.application_jupyter&.installed?
end
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
describe '#can_uninstall?' do
subject { ingress.can_uninstall? }
it 'returns true if external ip is set and no application exists' do
ingress.external_ip = 'IP'
context 'with jupyter installed' do
before do
create(:clusters_applications_jupyter, :installed, cluster: ingress.cluster)
end
is_expected.to be_truthy
end
it 'returns false if external_ip_or_hostname? is true' do
ingress.external_ip = 'IP'
it 'returns false if application_jupyter_nil_or_installable? is false' do
create(:clusters_applications_jupyter, :installed, cluster: ingress.cluster)
is_expected.to be_falsey
end
is_expected.to be_falsey
it 'returns false if external_ip_or_hostname? is false' do
is_expected.to be_falsey
end
end
it 'returns false if application_elastic_stack_nil_or_installable? is false' do
create(:clusters_applications_elastic_stack, :installed, cluster: ingress.cluster)
context 'with jupyter installable' do
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
it 'returns false if external_ip_or_hostname? is false' do
is_expected.to be_falsey
context 'with jupyter nil' do
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
......
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