diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/finders/bulk_imports | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/finders/bulk_imports')
-rw-r--r-- | spec/finders/bulk_imports/entities_finder_spec.rb | 32 | ||||
-rw-r--r-- | spec/finders/bulk_imports/imports_finder_spec.rb | 24 |
2 files changed, 51 insertions, 5 deletions
diff --git a/spec/finders/bulk_imports/entities_finder_spec.rb b/spec/finders/bulk_imports/entities_finder_spec.rb index e053011b60d..54c792cb4d8 100644 --- a/spec/finders/bulk_imports/entities_finder_spec.rb +++ b/spec/finders/bulk_imports/entities_finder_spec.rb @@ -51,7 +51,7 @@ RSpec.describe BulkImports::EntitiesFinder do end context 'when status is specified' do - subject { described_class.new(user: user, status: 'failed') } + subject { described_class.new(user: user, params: { status: 'failed' }) } it 'returns a list of import entities filtered by status' do expect(subject.execute) @@ -61,7 +61,7 @@ RSpec.describe BulkImports::EntitiesFinder do end context 'when invalid status is specified' do - subject { described_class.new(user: user, status: 'invalid') } + subject { described_class.new(user: user, params: { status: 'invalid' }) } it 'does not filter entities by status' do expect(subject.execute) @@ -74,11 +74,37 @@ RSpec.describe BulkImports::EntitiesFinder do end context 'when bulk import and status are specified' do - subject { described_class.new(user: user, bulk_import: user_import_2, status: 'finished') } + subject { described_class.new(user: user, bulk_import: user_import_2, params: { status: 'finished' }) } it 'returns matched import entities' do expect(subject.execute).to contain_exactly(finished_entity_2) end end + + context 'when order is specifed' do + subject { described_class.new(user: user, params: { sort: order }) } + + context 'when order is specified as asc' do + let(:order) { :asc } + + it 'returns entities sorted ascending' do + expect(subject.execute).to eq([ + started_entity_1, finished_entity_1, failed_entity_1, + started_entity_2, finished_entity_2, failed_entity_2 + ]) + end + end + + context 'when order is specified as desc' do + let(:order) { :desc } + + it 'returns entities sorted descending' do + expect(subject.execute).to eq([ + failed_entity_2, finished_entity_2, started_entity_2, + failed_entity_1, finished_entity_1, started_entity_1 + ]) + end + end + end end end diff --git a/spec/finders/bulk_imports/imports_finder_spec.rb b/spec/finders/bulk_imports/imports_finder_spec.rb index aac83c86c84..2f550514a33 100644 --- a/spec/finders/bulk_imports/imports_finder_spec.rb +++ b/spec/finders/bulk_imports/imports_finder_spec.rb @@ -16,19 +16,39 @@ RSpec.describe BulkImports::ImportsFinder do end context 'when status is specified' do - subject { described_class.new(user: user, status: 'started') } + subject { described_class.new(user: user, params: { status: 'started' }) } it 'returns a list of import entities filtered by status' do expect(subject.execute).to contain_exactly(started_import) end context 'when invalid status is specified' do - subject { described_class.new(user: user, status: 'invalid') } + subject { described_class.new(user: user, params: { status: 'invalid' }) } it 'does not filter entities by status' do expect(subject.execute).to contain_exactly(started_import, finished_import) end end end + + context 'when order is specifed' do + subject { described_class.new(user: user, params: { sort: order }) } + + context 'when order is specified as asc' do + let(:order) { :asc } + + it 'returns entities sorted ascending' do + expect(subject.execute).to eq([started_import, finished_import]) + end + end + + context 'when order is specified as desc' do + let(:order) { :desc } + + it 'returns entities sorted descending' do + expect(subject.execute).to eq([finished_import, started_import]) + end + end + end end end |