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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 17:40:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 17:40:33 +0300
commit42dd2634e347e42dc100596a6b2588e5f163322e (patch)
tree4c1e5ceb817a5739ffc79f5a16c475fda5ad9de9 /spec
parent93fd80667dcfbacca2b41168da6fcb3f67c0899b (diff)
Add latest changes from gitlab-org/security/gitlab@15-3-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/models/issue_spec.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 15fe6d7625a..af4c48775ec 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -823,14 +823,22 @@ RSpec.describe Issue do
end
describe '#to_branch_name exists ending with -index' do
- before do
+ it 'returns #to_branch_name ending with max index + 1' do
allow(repository).to receive(:branch_exists?).and_return(true)
allow(repository).to receive(:branch_exists?).with("#{subject.to_branch_name}-3").and_return(false)
- end
- it 'returns #to_branch_name ending with max index + 1' do
expect(subject.suggested_branch_name).to eq("#{subject.to_branch_name}-3")
end
+
+ context 'when branch name still exists after 5 attempts' do
+ it 'returns #to_branch_name ending with random characters' do
+ allow(repository).to receive(:branch_exists?).with(subject.to_branch_name).and_return(true)
+ allow(repository).to receive(:branch_exists?).with(/#{subject.to_branch_name}-\d/).and_return(true)
+ allow(repository).to receive(:branch_exists?).with(/#{subject.to_branch_name}-\h{8}/).and_return(false)
+
+ expect(subject.suggested_branch_name).to match(/#{subject.to_branch_name}-\h{8}/)
+ end
+ end
end
end