diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-12 03:11:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-12 03:11:58 +0300 |
commit | b5d655aea242b952abb8c020482fe8b810cb4d30 (patch) | |
tree | de079a7d28e6fe74466ecfc96f84249bbacdb1dc /spec | |
parent | 19d036837caf9f9618ee7f27808cb51f8d6c14e1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/submodules/update_service_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/services/submodules/update_service_spec.rb b/spec/services/submodules/update_service_spec.rb index b4282b2a89b..f4b8a3db29c 100644 --- a/spec/services/submodules/update_service_spec.rb +++ b/spec/services/submodules/update_service_spec.rb @@ -53,6 +53,84 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end context 'validations' do + context 'when submodule' do + context 'is empty' do + let(:submodule) { '' } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + + context 'is not present' do + let(:submodule) { nil } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + + context 'is invalid' do + let(:submodule) { 'VERSION' } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid submodule path' } + end + end + + context 'does not exist' do + let(:submodule) { 'non-existent-submodule' } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid submodule path' } + end + end + + # Can be re-enabled when problem from https://gitlab.com/gitlab-org/gitlab/-/issues/413964#note_1421909142 + # is fixed + # context 'has traversal path' do + # let(:submodule) { '../six' } + + # it_behaves_like 'returns error result' do + # let(:error_message) { 'Invalid submodule path' } + # end + # end + end + + context 'commit_sha' do + context 'is empty' do + let(:commit_sha) { '' } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + + context 'is not present' do + let(:commit_sha) { nil } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + + context 'is invalid' do + let(:commit_sha) { '1' } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + + context 'is the same as the current ref' do + let(:commit_sha) { current_sha } + + it_behaves_like 'returns error result' do + let(:error_message) { "The submodule #{submodule} is already at #{commit_sha}" } + end + end + end + context 'branch_name' do context 'is empty' do let(:branch_name) { '' } @@ -62,6 +140,14 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end end + context 'is not present' do + let(:branch_name) { nil } + + it_behaves_like 'returns error result' do + let(:error_message) { 'Invalid parameters' } + end + end + context 'does not exist' do let(:branch_name) { 'non/existent-branch' } |