summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-05 12:06:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-05 12:06:20 +0000
commit791785af5540d18eaa97da24f9ff8638e1960b72 (patch)
treecaeb6f08d9cc10a0052dc6851b46653d94c29022 /spec/finders
parenta92d6b36c2d2892e8c070efb169f0c06815900ee (diff)
downloadgitlab-ce-791785af5540d18eaa97da24f9ff8638e1960b72.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/branches_finder_spec.rb56
-rw-r--r--spec/finders/tags_finder_spec.rb38
2 files changed, 75 insertions, 19 deletions
diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb
index 1a33bdf11d7..70b5da0cc3c 100644
--- a/spec/finders/branches_finder_spec.rb
+++ b/spec/finders/branches_finder_spec.rb
@@ -73,58 +73,76 @@ describe BranchesFinder do
expect(result.count).to eq(3)
expect(result.map(&:name)).to eq(%w{csv fix lfs})
end
- end
- context 'filter and sort' do
- it 'filters branches by name and sorts by recently_updated' do
- params = { sort: 'updated_desc', search: 'feat' }
+ it 'filters branches by name that begins with' do
+ params = { search: '^feature_' }
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
expect(result.first.name).to eq('feature_conflict')
- expect(result.count).to eq(2)
+ expect(result.count).to eq(1)
end
- it 'filters branches by name and sorts by recently_updated, with exact matches first' do
- params = { sort: 'updated_desc', search: 'feature' }
+ it 'filters branches by name that ends with' do
+ params = { search: 'feature$' }
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
expect(result.first.name).to eq('feature')
- expect(result.second.name).to eq('feature_conflict')
- expect(result.count).to eq(2)
+ expect(result.count).to eq(1)
end
- it 'filters branches by name and sorts by last_updated' do
- params = { sort: 'updated_asc', search: 'feature' }
+ it 'filters branches by nonexistent name that begins with' do
+ params = { search: '^nope' }
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature')
- expect(result.count).to eq(2)
+ expect(result.count).to eq(0)
end
- it 'filters branches by name that begins with' do
- params = { search: '^feature_' }
+ it 'filters branches by nonexistent name that ends with' do
+ params = { search: 'nope$' }
+ branches_finder = described_class.new(repository, params)
+
+ result = branches_finder.execute
+
+ expect(result.count).to eq(0)
+ end
+ end
+
+ context 'filter and sort' do
+ it 'filters branches by name and sorts by recently_updated' do
+ params = { sort: 'updated_desc', search: 'feat' }
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
expect(result.first.name).to eq('feature_conflict')
- expect(result.count).to eq(1)
+ expect(result.count).to eq(2)
end
- it 'filters branches by name that ends with' do
- params = { search: 'feature$' }
+ it 'filters branches by name and sorts by recently_updated, with exact matches first' do
+ params = { sort: 'updated_desc', search: 'feature' }
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
expect(result.first.name).to eq('feature')
- expect(result.count).to eq(1)
+ expect(result.second.name).to eq('feature_conflict')
+ expect(result.count).to eq(2)
+ end
+
+ it 'filters branches by name and sorts by last_updated' do
+ params = { sort: 'updated_asc', search: 'feature' }
+ branches_finder = described_class.new(repository, params)
+
+ result = branches_finder.execute
+
+ expect(result.first.name).to eq('feature')
+ expect(result.count).to eq(2)
end
end
end
diff --git a/spec/finders/tags_finder_spec.rb b/spec/finders/tags_finder_spec.rb
index 85f970b71c4..e9f29ab2441 100644
--- a/spec/finders/tags_finder_spec.rb
+++ b/spec/finders/tags_finder_spec.rb
@@ -54,6 +54,44 @@ describe TagsFinder do
expect(result.count).to eq(0)
end
+
+ it 'filters tags by name that begins with' do
+ params = { search: '^v1.0' }
+ tags_finder = described_class.new(repository, params)
+
+ result = tags_finder.execute
+
+ expect(result.first.name).to eq('v1.0.0')
+ expect(result.count).to eq(1)
+ end
+
+ it 'filters tags by name that ends with' do
+ params = { search: '0.0$' }
+ tags_finder = described_class.new(repository, params)
+
+ result = tags_finder.execute
+
+ expect(result.first.name).to eq('v1.0.0')
+ expect(result.count).to eq(1)
+ end
+
+ it 'filters tags by nonexistent name that begins with' do
+ params = { search: '^nope' }
+ tags_finder = described_class.new(repository, params)
+
+ result = tags_finder.execute
+
+ expect(result.count).to eq(0)
+ end
+
+ it 'filters tags by nonexistent name that ends with' do
+ params = { search: 'nope$' }
+ tags_finder = described_class.new(repository, params)
+
+ result = tags_finder.execute
+
+ expect(result.count).to eq(0)
+ end
end
context 'filter and sort' do