Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb')
-rw-r--r--spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb b/spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb
index 4ce51e37685..00beacd4b35 100644
--- a/spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb
+++ b/spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb
@@ -41,14 +41,40 @@ RSpec.describe Gitlab::Pagination::Keyset::InOperatorOptimization::QueryBuilder
)
end
- it 'returns records in correct order' do
+ let(:all_records) do
all_records = []
iterator.each_batch(of: batch_size) do |records|
all_records.concat(records)
end
+ all_records
+ end
+ it 'returns records in correct order' do
expect(all_records).to eq(expected_order)
end
+
+ context 'when not passing the finder query' do
+ before do
+ in_operator_optimization_options.delete(:finder_query)
+ end
+
+ it 'returns records in correct order' do
+ expect(all_records).to eq(expected_order)
+ end
+
+ it 'loads only the order by column' do
+ order_by_attribute_names = iterator
+ .send(:order)
+ .column_definitions
+ .map(&:attribute_name)
+ .map(&:to_s)
+
+ record = all_records.first
+ loaded_attributes = record.attributes.keys - ['time_estimate'] # time_estimate is always present (has default value)
+
+ expect(loaded_attributes).to eq(order_by_attribute_names)
+ end
+ end
end
context 'when ordering by issues.id DESC' do