diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-12-05 10:22:07 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-12-05 10:22:07 +0000 |
commit | c1390bd98ccb0368f700117097f47d6ff488fdba (patch) | |
tree | c4f383b778c8a3d33bdbb82d84c8fd7a91d3fbdf /spec/lib/api/helpers/pagination_spec.rb | |
parent | e416d6ff1d020ec510ab71bfdbcfbc72b14cd44a (diff) | |
parent | 4ca4b0ff702a68a9aed5da70d9170da410eefafa (diff) | |
download | gitlab-ce-38869-templates.tar.gz |
Merge branch 'master' into 38869-templates38869-templates
* master: (50 commits)
remove ambiguity about which resource type to be using for new sessions
Backport changes from refactor sidebar weight block Vue and move to Issue Boards
Migrate Gitlab::Git::Repository#cherry_pick to Gitaly
show status of issue links in wiki page
issue note component rename
Prevent job link form rendering when user does not have permissions
Move SingleRepositoryWorker#fsck into Gitlab::Git::Repository
Import axios utils in commons
Update parser gem to remove warning about wrong ruby version
Merge branch 'master-i18n' into 'master'
Reduce pipeline chain life span to minimize side effects
Add CHANGELOG entry
Refactor GCP Client#user_agent_header to use #tap
Remove seed file from the development env
Fixed bug
Fix watch level for mentions in description
Add notice to gollum initializer
Add underline hover state to all links
Moving query to base count service
Added default order to UserFinder
...
Diffstat (limited to 'spec/lib/api/helpers/pagination_spec.rb')
-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 |