summaryrefslogtreecommitdiff
path: root/spec/models/issue_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/issue_spec.rb')
-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 d45a23a7ef8..eaa95de54b9 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -640,14 +640,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