diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/models/repository_spec.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 84347ec2a51..a739f523008 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -170,6 +170,22 @@ RSpec.describe Repository do end end + describe '#search_branch_names' do + subject(:search_branch_names) { repository.search_branch_names('conflict-*') } + + it 'returns matching branch names' do + expect(search_branch_names).to contain_exactly( + 'conflict-binary-file', + 'conflict-resolvable', + 'conflict-contains-conflict-markers', + 'conflict-missing-side', + 'conflict-start', + 'conflict-non-utf8', + 'conflict-too-large' + ) + end + end + describe '#list_last_commits_for_tree' do let(:path_to_commit) do { @@ -977,6 +993,57 @@ RSpec.describe Repository do end end + describe '#search_files_by_wildcard_path' do + let(:ref) { 'master' } + + subject(:result) { repository.search_files_by_wildcard_path(path, ref) } + + context 'when specifying a normal path' do + let(:path) { 'files/images/logo-black.png' } + + it 'returns the path' do + expect(result).to eq(['files/images/logo-black.png']) + end + end + + context 'when specifying a path with wildcard' do + let(:path) { 'files/*/*.png' } + + it 'returns all files matching the path' do + expect(result).to contain_exactly('files/images/logo-black.png', + 'files/images/logo-white.png') + end + end + + context 'when specifying an extension with wildcard' do + let(:path) { '*.rb' } + + it 'returns all files matching the extension' do + expect(result).to contain_exactly('encoding/russian.rb', + 'files/ruby/popen.rb', + 'files/ruby/regex.rb', + 'files/ruby/version_info.rb') + end + end + + context 'when sending regexp' do + let(:path) { '.*\.rb' } + + it 'ignores the regexp and returns an empty array' do + expect(result).to eq([]) + end + end + + context 'when sending another ref' do + let(:path) { 'files' } + let(:ref) { 'other-branch' } + + it 'returns an empty array' do + expect(result).to eq([]) + end + end + end + describe '#async_remove_remote' do before do masterrev = repository.find_branch('master').dereferenced_target @@ -1036,7 +1103,8 @@ RSpec.describe Repository do describe '#create_ref' do it 'redirects the call to write_ref' do - ref, ref_path = '1', '2' + ref = '1' + ref_path = '2' expect(repository.raw_repository).to receive(:write_ref).with(ref_path, ref) @@ -1647,12 +1715,13 @@ RSpec.describe Repository do end it 'writes merge of source SHA and first parent ref to MR merge_ref_path' do - merge_commit_id = repository.merge_to_ref(user, - merge_request.diff_head_sha, - merge_request, - merge_request.merge_ref_path, - 'Custom message', - merge_request.target_branch_ref) + merge_commit_id = + repository.merge_to_ref(user, + source_sha: merge_request.diff_head_sha, + branch: merge_request.target_branch, + target_ref: merge_request.merge_ref_path, + message: 'Custom message', + first_parent_ref: merge_request.target_branch_ref) merge_commit = repository.commit(merge_commit_id) |