diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-19 23:18:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-19 23:18:09 +0000 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/lib/gitlab/pagination | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) | |
download | gitlab-ce-6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde.tar.gz |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/lib/gitlab/pagination')
-rw-r--r-- | spec/lib/gitlab/pagination/keyset/column_order_definition_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/gitlab/pagination/keyset/column_order_definition_spec.rb b/spec/lib/gitlab/pagination/keyset/column_order_definition_spec.rb index 778244677ef..100574cc75f 100644 --- a/spec/lib/gitlab/pagination/keyset/column_order_definition_spec.rb +++ b/spec/lib/gitlab/pagination/keyset/column_order_definition_spec.rb @@ -50,6 +50,20 @@ RSpec.describe Gitlab::Pagination::Keyset::ColumnOrderDefinition do it { expect(project_calculated_column).to be_ascending_order } it { expect(project_calculated_column).not_to be_descending_order } + context 'when order expression is an Arel node with nulls_last' do + it 'can automatically determine the reversed expression' do + column_order_definition = described_class.new( + attribute_name: :name, + column_expression: Project.arel_table[:name], + order_expression: Project.arel_table[:name].asc.nulls_last, + nullable: :nulls_last, + distinct: false + ) + + expect(column_order_definition).to be_ascending_order + end + end + it 'raises error when order direction cannot be infered' do expect do described_class.new( @@ -132,6 +146,21 @@ RSpec.describe Gitlab::Pagination::Keyset::ColumnOrderDefinition do expect(column_order_definition.reverse.order_expression).to eq('name desc') end end + + context 'when order expression is an Arel node with nulls_last' do + it 'can automatically determine the reversed expression' do + column_order_definition = described_class.new( + attribute_name: :name, + column_expression: Project.arel_table[:name], + order_expression: Project.arel_table[:name].asc.nulls_last, + order_direction: :asc, + nullable: :nulls_last, + distinct: false + ) + + expect(column_order_definition.reverse.order_expression).to eq(Project.arel_table[:name].desc.nulls_first) + end + end end describe '#nullable' do |