diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2017-12-04 09:49:53 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-12-04 09:49:53 +0000 |
commit | 7c2b7296d4e623ba4eaa19cf03405ee7f2ae1ca9 (patch) | |
tree | 80784f83c52313797b8cf7e78ccf8db66f0880d8 /spec | |
parent | c997c95dfca2c3d30f8c7b8ef5f0fd95c1356226 (diff) | |
download | gitlab-ce-7c2b7296d4e623ba4eaa19cf03405ee7f2ae1ca9.tar.gz |
Added default order to UserFinder
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/api/helpers/pagination_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/api/helpers/pagination_spec.rb b/spec/lib/api/helpers/pagination_spec.rb index 59deca7757b..a547988d631 100644 --- a/spec/lib/api/helpers/pagination_spec.rb +++ b/spec/lib/api/helpers/pagination_spec.rb @@ -92,6 +92,27 @@ describe API::Helpers::Pagination do subject.paginate(resource) end end + + context 'if order' do + it 'is not present it adds default order(:id) if no order is present' do + resource.order_values = [] + + paginated_relation = subject.paginate(resource) + + expect(resource.order_values).to be_empty + expect(paginated_relation.order_values).to be_present + expect(paginated_relation.order_values.first).to be_ascending + expect(paginated_relation.order_values.first.expr.name).to eq :id + end + + it 'is present it does not add anything' do + paginated_relation = subject.paginate(resource.order(created_at: :desc)) + + expect(paginated_relation.order_values).to be_present + expect(paginated_relation.order_values.first).to be_descending + expect(paginated_relation.order_values.first.expr.name).to eq :created_at + end + end end context 'when resource empty' do |