diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-16 06:08:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-16 06:08:27 +0000 |
commit | 36c3f8296f0309642d3b41b7d0e0333e50ac75a6 (patch) | |
tree | 86fc05e07f33599ae15319251d17b5060c6c52af /spec/requests/api/project_container_repositories_spec.rb | |
parent | e8d7ac4f14bcc70921ea9d63c75cd2e7f2cd5c31 (diff) | |
download | gitlab-ce-36c3f8296f0309642d3b41b7d0e0333e50ac75a6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/project_container_repositories_spec.rb')
-rw-r--r-- | spec/requests/api/project_container_repositories_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/project_container_repositories_spec.rb b/spec/requests/api/project_container_repositories_spec.rb index 91905635c3f..471fc99117b 100644 --- a/spec/requests/api/project_container_repositories_spec.rb +++ b/spec/requests/api/project_container_repositories_spec.rb @@ -223,6 +223,40 @@ describe API::ProjectContainerRepositories do expect(response).to have_gitlab_http_status(:accepted) end end + + context 'with invalid regex' do + let(:invalid_regex) { '*v10.' } + let(:lease_key) { "container_repository:cleanup_tags:#{root_repository.id}" } + + RSpec.shared_examples 'rejecting the invalid regex' do |param_name| + it 'does not enqueue a job' do + expect(CleanupContainerRepositoryWorker).not_to receive(:perform_async) + + subject + end + + it_behaves_like 'returning response status', :bad_request + + it 'returns an error message' do + subject + + expect(json_response['error']).to include("#{param_name} is an invalid regexp") + end + end + + before do + stub_last_activity_update + stub_exclusive_lease(lease_key, timeout: 1.hour) + end + + %i[name_regex_delete name_regex name_regex_keep].each do |param_name| + context "for #{param_name}" do + let(:params) { { param_name => invalid_regex } } + + it_behaves_like 'rejecting the invalid regex', param_name + end + end + end end end |