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

last_items_spec.rb « keyset « pagination « graphql « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 792cb03e8c7aa716ab9098609dbf75aea2c6e0f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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 }

  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