diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 15:09:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 15:09:03 +0000 |
commit | cb840235d7fb4001dab266c614bd2cf59036fe18 (patch) | |
tree | b2c8cfa706d4e2c20dfe6d6e7936deeb3025352c /spec/models/repository_spec.rb | |
parent | 359f9c9929177d6ea6c54c19b23959145f177a78 (diff) | |
download | gitlab-ce-cb840235d7fb4001dab266c614bd2cf59036fe18.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 84347ec2a51..0ad8c5ffc0d 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -977,6 +977,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 |