debian-mirror-gitlab/spec/lib/api/helpers/pagination_spec.rb

23 lines
680 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe API::Helpers::Pagination do
2019-12-26 22:10:19 +05:30
subject { Class.new.include(described_class).new }
2019-09-04 21:01:54 +05:30
2019-12-26 22:10:19 +05:30
describe '#paginate' do
let(:relation) { double("relation") }
let(:offset_pagination) { double("offset pagination") }
let(:expected_result) { double("result") }
2019-03-02 22:35:43 +05:30
2019-12-26 22:10:19 +05:30
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)
2019-03-02 22:35:43 +05:30
2019-12-26 22:10:19 +05:30
result = subject.paginate(relation)
2017-08-17 22:00:37 +05:30
2019-12-26 22:10:19 +05:30
expect(result).to eq(expected_result)
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
end
end