2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-22 07:50:45 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe API::Helpers::Pagination do
|
2019-10-29 05:06:10 -04:00
|
|
|
subject { Class.new.include(described_class).new }
|
2019-06-06 08:15:26 -04:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
let(:paginator) { double('paginator') }
|
|
|
|
let(:relation) { double('relation') }
|
|
|
|
let(:expected_result) { double('expected result') }
|
2019-12-06 13:07:44 -05:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it 'delegates to OffsetPagination' do
|
|
|
|
expect(Gitlab::Pagination::OffsetPagination).to receive(:new).with(subject).and_return(paginator)
|
|
|
|
expect(paginator).to receive(:paginate).with(relation).and_return(expected_result)
|
2019-12-06 13:07:44 -05:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
expect(subject.paginate(relation)).to eq(expected_result)
|
2019-12-06 13:07:44 -05:00
|
|
|
end
|
2016-12-22 07:50:45 -05:00
|
|
|
end
|