diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/finders/snippets_finder_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/finders/snippets_finder_spec.rb')
-rw-r--r-- | spec/finders/snippets_finder_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb index 0affc832b30..6fc1cbcee0a 100644 --- a/spec/finders/snippets_finder_spec.rb +++ b/spec/finders/snippets_finder_spec.rb @@ -283,6 +283,12 @@ RSpec.describe SnippetsFinder do it 'returns only personal snippets when the user cannot read cross project' do expect(described_class.new(user).execute).to contain_exactly(private_personal_snippet, internal_personal_snippet, public_personal_snippet) end + + context 'when only project snippets are required' do + it 'returns no records' do + expect(described_class.new(user, only_project: true).execute).to be_empty + end + end end context 'when project snippets are disabled' do @@ -295,6 +301,22 @@ RSpec.describe SnippetsFinder do expect(finder.execute).to be_empty end end + + context 'no sort param is provided' do + it 'returns snippets sorted by id' do + snippets = described_class.new(admin).execute + + expect(snippets.ids).to eq(Snippet.order_id_desc.ids) + end + end + + context 'sort param is provided' do + it 'returns snippets sorted by sort param' do + snippets = described_class.new(admin, sort: 'updated_desc').execute + + expect(snippets.ids).to eq(Snippet.order_updated_desc.ids) + end + end end it_behaves_like 'snippet visibility' |