diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/finders/container_repositories_finder_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/finders/container_repositories_finder_spec.rb')
-rw-r--r-- | spec/finders/container_repositories_finder_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/finders/container_repositories_finder_spec.rb b/spec/finders/container_repositories_finder_spec.rb index b6305e3f5b7..983f6dba28b 100644 --- a/spec/finders/container_repositories_finder_spec.rb +++ b/spec/finders/container_repositories_finder_spec.rb @@ -32,6 +32,34 @@ RSpec.describe ContainerRepositoriesFinder do end end + shared_examples 'with sorting' do + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:sort_repository) do + create(:container_repository, name: 'bar', project: project, created_at: 1.day.ago) + end + + let_it_be(:sort_repository2) do + create(:container_repository, name: 'foo', project: project, created_at: 1.hour.ago, updated_at: 1.hour.ago) + end + + [:created_desc, :updated_asc, :name_desc].each do |order| + context "with sort set to #{order}" do + let(:params) { { sort: order } } + + it { is_expected.to eq([sort_repository2, sort_repository])} + end + end + + [:created_asc, :updated_desc, :name_asc].each do |order| + context "with sort set to #{order}" do + let(:params) { { sort: order } } + + it { is_expected.to eq([sort_repository, sort_repository2])} + end + end + end + describe '#execute' do context 'with authorized user' do subject { described_class.new(user: reporter, subject: subject_object, params: params).execute } @@ -47,6 +75,7 @@ RSpec.describe ContainerRepositoriesFinder do it { is_expected.to match_array([project_repository, other_repository]) } it_behaves_like 'with name search' + it_behaves_like 'with sorting' end context 'when subject_type is project' do @@ -55,6 +84,7 @@ RSpec.describe ContainerRepositoriesFinder do it { is_expected.to match_array([project_repository]) } it_behaves_like 'with name search' + it_behaves_like 'with sorting' end context 'with invalid subject_type' do |