Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Cunha <j.a.cunha@gmail.com>2019-09-11 20:48:50 +0300
committerJoão Cunha <j.a.cunha@gmail.com>2019-09-12 12:28:24 +0300
commitc69ceaf5ff5ad9143467cc7f4512086d582328e7 (patch)
tree2859e3944f33eb7cbc88c87cbd616a860dc80b93
parent66d9be244c873b3f43431b81719f71d250830896 (diff)
App can_uninstall? only if installed or uninstall_errored
-rw-r--r--app/models/clusters/concerns/application_core.rb6
-rw-r--r--spec/support/shared_examples/models/cluster_application_core_shared_examples.rb42
2 files changed, 29 insertions, 19 deletions
diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb
index 1924dbae7fc..b5388be283e 100644
--- a/app/models/clusters/concerns/application_core.rb
+++ b/app/models/clusters/concerns/application_core.rb
@@ -19,11 +19,11 @@ module Clusters
end
def can_uninstall?
- allowed_to_uninstall? && !scheduled_or_uninstalling?
+ allowed_to_uninstall? && uninstall_errored_or_installed?
end
- def scheduled_or_uninstalling?
- scheduled? || uninstalling?
+ def uninstall_errored_or_installed?
+ uninstall_errored? || installed?
end
# All new applications should uninstall by default
diff --git a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
index 82149d4f715..810dae419b9 100644
--- a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
@@ -5,30 +5,40 @@ shared_examples 'cluster application core specs' do |application_name|
it { is_expected.to validate_presence_of(:cluster) }
describe '#can_uninstall?' do
- it 'calls allowed_to_uninstall?' do
- expect(subject).to receive(:allowed_to_uninstall?).and_return(true)
+ using RSpec::Parameterized::TableSyntax
- expect(subject.can_uninstall?).to be_truthy
- end
+ before { allow(application).to receive(:allowed_to_uninstall?).and_return(allowed_to_uninstall_result) }
+
+ let(:application) { create(application_name, status) }
+ let(:status) { status_name }
+
+ context "when allowed_to_uninstall? is true" do
+ let(:allowed_to_uninstall_result) { true }
- context 'when neither scheduled or installed' do
- before do
- expect(subject.scheduled?).to be_falsey
- expect(subject.uninstalling?).to be_falsey
+ where(:expected_value, :status_name) do
+ true | :uninstall_errored
+ true | :installed
+ false | :scheduled
+ false | :uninstalling
end
- it { expect(subject.can_uninstall?).to be_truthy }
+ with_them do
+ it { expect(application.can_uninstall?).to eq expected_value }
+ end
end
- context 'when scheduled or uninstalling' do
- it 'returns false if scheduled' do
- application = create(application_name, :scheduled)
- expect(application.can_uninstall?).to be_falsey
+ context "when allowed_to_uninstall is false" do
+ let(:allowed_to_uninstall_result) { false }
+
+ where(:expected_value, :status_name) do
+ false | :uninstall_errored
+ false | :installed
+ false | :scheduled
+ false | :uninstalling
end
- it 'returns false if uninstalling' do
- application = create(application_name, :uninstalling)
- expect(application.can_uninstall?).to be_falsey
+ with_them do
+ it { expect(application.can_uninstall?).to eq expected_value }
end
end
end