diff options
Diffstat (limited to 'spec/lib/gitlab/graphql/pagination/keyset/last_items_spec.rb')
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/last_items_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/graphql/pagination/keyset/last_items_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/last_items_spec.rb new file mode 100644 index 00000000000..b45bb8b79d9 --- /dev/null +++ b/spec/lib/gitlab/graphql/pagination/keyset/last_items_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Graphql::Pagination::Keyset::LastItems do + let_it_be(:merge_request) { create(:merge_request) } + let(:scope) { MergeRequest.order_merged_at_asc.with_order_id_desc } + + subject { described_class.take_items(*args) } + + context 'when the `count` parameter is nil' do + let(:args) { [scope, nil] } + + it 'returns a single record' do + expect(subject).to eq(merge_request) + end + end + + context 'when the `count` parameter is given' do + let(:args) { [scope, 1] } + + it 'returns an array' do + expect(subject).to eq([merge_request]) + end + end +end |