summaryrefslogtreecommitdiff
path: root/spec/models/repository_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-17 15:09:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-17 15:09:03 +0000
commitcb840235d7fb4001dab266c614bd2cf59036fe18 (patch)
treeb2c8cfa706d4e2c20dfe6d6e7936deeb3025352c /spec/models/repository_spec.rb
parent359f9c9929177d6ea6c54c19b23959145f177a78 (diff)
downloadgitlab-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.rb51
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