summaryrefslogtreecommitdiff
path: root/spec/helpers/packages_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/packages_helper_spec.rb')
-rw-r--r--spec/helpers/packages_helper_spec.rb169
1 files changed, 162 insertions, 7 deletions
diff --git a/spec/helpers/packages_helper_spec.rb b/spec/helpers/packages_helper_spec.rb
index dacd386d01c..93d32cb8418 100644
--- a/spec/helpers/packages_helper_spec.rb
+++ b/spec/helpers/packages_helper_spec.rb
@@ -3,11 +3,13 @@
require 'spec_helper'
RSpec.describe PackagesHelper do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be_with_reload(:project) { create(:project) }
let_it_be(:base_url) { "#{Gitlab.config.gitlab.url}/api/v4/" }
- let_it_be(:project) { create(:project) }
- describe 'package_registry_instance_url' do
- it 'returns conant instance url when registry_type is conant' do
+ describe '#package_registry_instance_url' do
+ it 'returns conan instance url when registry_type is conant' do
url = helper.package_registry_instance_url(:conan)
expect(url).to eq("#{base_url}packages/conan")
@@ -20,7 +22,7 @@ RSpec.describe PackagesHelper do
end
end
- describe 'package_registry_project_url' do
+ describe '#package_registry_project_url' do
it 'returns maven registry url when registry_type is not provided' do
url = helper.package_registry_project_url(1)
@@ -34,7 +36,7 @@ RSpec.describe PackagesHelper do
end
end
- describe 'pypi_registry_url' do
+ describe '#pypi_registry_url' do
let_it_be(:base_url_with_token) { base_url.sub('://', '://__token__:<your_personal_token>@') }
it 'returns the pypi registry url' do
@@ -44,7 +46,7 @@ RSpec.describe PackagesHelper do
end
end
- describe 'composer_registry_url' do
+ describe '#composer_registry_url' do
it 'return the composer registry url' do
url = helper.composer_registry_url(1)
@@ -52,7 +54,7 @@ RSpec.describe PackagesHelper do
end
end
- describe 'composer_config_repository_name' do
+ describe '#composer_config_repository_name' do
let(:host) { Gitlab.config.gitlab.host }
let(:group_id) { 1 }
@@ -62,4 +64,157 @@ RSpec.describe PackagesHelper do
expect(id).to eq("#{host}/#{group_id}")
end
end
+
+ describe '#show_cleanup_policy_on_alert' do
+ let_it_be_with_reload(:container_repository) { create(:container_repository) }
+
+ subject { helper.show_cleanup_policy_on_alert(project.reload) }
+
+ where(:com, :config_registry, :project_registry, :historic_entries, :historic_entry, :nil_policy, :container_repositories_exist, :expected_result) do
+ false | false | false | false | false | false | false | false
+ false | false | false | false | false | false | true | false
+ false | false | false | false | false | true | false | false
+ false | false | false | false | false | true | true | false
+ false | false | false | false | true | false | false | false
+ false | false | false | false | true | false | true | false
+ false | false | false | false | true | true | false | false
+ false | false | false | false | true | true | true | false
+ false | false | false | true | false | false | false | false
+ false | false | false | true | false | false | true | false
+ false | false | false | true | false | true | false | false
+ false | false | false | true | false | true | true | false
+ false | false | false | true | true | false | false | false
+ false | false | false | true | true | false | true | false
+ false | false | false | true | true | true | false | false
+ false | false | false | true | true | true | true | false
+ false | false | true | false | false | false | false | false
+ false | false | true | false | false | false | true | false
+ false | false | true | false | false | true | false | false
+ false | false | true | false | false | true | true | false
+ false | false | true | false | true | false | false | false
+ false | false | true | false | true | false | true | false
+ false | false | true | false | true | true | false | false
+ false | false | true | false | true | true | true | false
+ false | false | true | true | false | false | false | false
+ false | false | true | true | false | false | true | false
+ false | false | true | true | false | true | false | false
+ false | false | true | true | false | true | true | false
+ false | false | true | true | true | false | false | false
+ false | false | true | true | true | false | true | false
+ false | false | true | true | true | true | false | false
+ false | false | true | true | true | true | true | false
+ false | true | false | false | false | false | false | false
+ false | true | false | false | false | false | true | false
+ false | true | false | false | false | true | false | false
+ false | true | false | false | false | true | true | false
+ false | true | false | false | true | false | false | false
+ false | true | false | false | true | false | true | false
+ false | true | false | false | true | true | false | false
+ false | true | false | false | true | true | true | false
+ false | true | false | true | false | false | false | false
+ false | true | false | true | false | false | true | false
+ false | true | false | true | false | true | false | false
+ false | true | false | true | false | true | true | false
+ false | true | false | true | true | false | false | false
+ false | true | false | true | true | false | true | false
+ false | true | false | true | true | true | false | false
+ false | true | false | true | true | true | true | false
+ false | true | true | false | false | false | false | false
+ false | true | true | false | false | false | true | false
+ false | true | true | false | false | true | false | false
+ false | true | true | false | false | true | true | false
+ false | true | true | false | true | false | false | false
+ false | true | true | false | true | false | true | false
+ false | true | true | false | true | true | false | false
+ false | true | true | false | true | true | true | false
+ false | true | true | true | false | false | false | false
+ false | true | true | true | false | false | true | false
+ false | true | true | true | false | true | false | false
+ false | true | true | true | false | true | true | false
+ false | true | true | true | true | false | false | false
+ false | true | true | true | true | false | true | false
+ false | true | true | true | true | true | false | false
+ false | true | true | true | true | true | true | false
+ true | false | false | false | false | false | false | false
+ true | false | false | false | false | false | true | false
+ true | false | false | false | false | true | false | false
+ true | false | false | false | false | true | true | false
+ true | false | false | false | true | false | false | false
+ true | false | false | false | true | false | true | false
+ true | false | false | false | true | true | false | false
+ true | false | false | false | true | true | true | false
+ true | false | false | true | false | false | false | false
+ true | false | false | true | false | false | true | false
+ true | false | false | true | false | true | false | false
+ true | false | false | true | false | true | true | false
+ true | false | false | true | true | false | false | false
+ true | false | false | true | true | false | true | false
+ true | false | false | true | true | true | false | false
+ true | false | false | true | true | true | true | false
+ true | false | true | false | false | false | false | false
+ true | false | true | false | false | false | true | false
+ true | false | true | false | false | true | false | false
+ true | false | true | false | false | true | true | false
+ true | false | true | false | true | false | false | false
+ true | false | true | false | true | false | true | false
+ true | false | true | false | true | true | false | false
+ true | false | true | false | true | true | true | false
+ true | false | true | true | false | false | false | false
+ true | false | true | true | false | false | true | false
+ true | false | true | true | false | true | false | false
+ true | false | true | true | false | true | true | false
+ true | false | true | true | true | false | false | false
+ true | false | true | true | true | false | true | false
+ true | false | true | true | true | true | false | false
+ true | false | true | true | true | true | true | false
+ true | true | false | false | false | false | false | false
+ true | true | false | false | false | false | true | false
+ true | true | false | false | false | true | false | false
+ true | true | false | false | false | true | true | false
+ true | true | false | false | true | false | false | false
+ true | true | false | false | true | false | true | false
+ true | true | false | false | true | true | false | false
+ true | true | false | false | true | true | true | false
+ true | true | false | true | false | false | false | false
+ true | true | false | true | false | false | true | false
+ true | true | false | true | false | true | false | false
+ true | true | false | true | false | true | true | false
+ true | true | false | true | true | false | false | false
+ true | true | false | true | true | false | true | false
+ true | true | false | true | true | true | false | false
+ true | true | false | true | true | true | true | false
+ true | true | true | false | false | false | false | false
+ true | true | true | false | false | false | true | false
+ true | true | true | false | false | true | false | false
+ true | true | true | false | false | true | true | false
+ true | true | true | false | true | false | false | false
+ true | true | true | false | true | false | true | false
+ true | true | true | false | true | true | false | false
+ true | true | true | false | true | true | true | true
+ true | true | true | true | false | false | false | false
+ true | true | true | true | false | false | true | false
+ true | true | true | true | false | true | false | false
+ true | true | true | true | false | true | true | false
+ true | true | true | true | true | false | false | false
+ true | true | true | true | true | false | true | false
+ true | true | true | true | true | true | false | false
+ true | true | true | true | true | true | true | false
+ end
+
+ with_them do
+ before do
+ allow(Gitlab).to receive(:com?).and_return(com)
+ stub_config(registry: { enabled: config_registry })
+ allow(project).to receive(:container_registry_enabled).and_return(project_registry)
+ stub_application_setting(container_expiration_policies_enable_historic_entries: historic_entries)
+ stub_feature_flags(container_expiration_policies_historic_entry: false)
+ stub_feature_flags(container_expiration_policies_historic_entry: project) if historic_entry
+
+ project.container_expiration_policy.destroy! if nil_policy
+ container_repository.update!(project_id: project.id) if container_repositories_exist
+ end
+
+ it { is_expected.to eq(expected_result) }
+ end
+ end
end