2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-22 07:50:45 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-10-29 05:06:10 -04:00
|
|
|
describe '#paginate' do
|
|
|
|
let(:relation) { double("relation") }
|
|
|
|
let(:offset_pagination) { double("offset pagination") }
|
|
|
|
let(:expected_result) { double("result") }
|
2018-12-19 07:03:40 -05:00
|
|
|
|
2019-10-29 05:06:10 -04:00
|
|
|
it 'delegates to OffsetPagination' do
|
|
|
|
expect(::Gitlab::Pagination::OffsetPagination).to receive(:new).with(subject).and_return(offset_pagination)
|
|
|
|
expect(offset_pagination).to receive(:paginate).with(relation).and_return(expected_result)
|
2018-12-19 07:03:40 -05:00
|
|
|
|
2019-10-29 05:06:10 -04:00
|
|
|
result = subject.paginate(relation)
|
2016-12-22 07:50:45 -05:00
|
|
|
|
2019-10-29 05:06:10 -04:00
|
|
|
expect(result).to eq(expected_result)
|
2017-08-17 06:11:40 -04:00
|
|
|
end
|
2016-12-22 07:50:45 -05:00
|
|
|
end
|
|
|
|
end
|