diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/lib/bulk_imports/pipeline/extracted_data_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/lib/bulk_imports/pipeline/extracted_data_spec.rb')
-rw-r--r-- | spec/lib/bulk_imports/pipeline/extracted_data_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/lib/bulk_imports/pipeline/extracted_data_spec.rb b/spec/lib/bulk_imports/pipeline/extracted_data_spec.rb new file mode 100644 index 00000000000..25c5178227a --- /dev/null +++ b/spec/lib/bulk_imports/pipeline/extracted_data_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe BulkImports::Pipeline::ExtractedData do + let(:data) { 'data' } + let(:has_next_page) { true } + let(:cursor) { 'cursor' } + let(:page_info) do + { + 'has_next_page' => has_next_page, + 'end_cursor' => cursor + } + end + + subject { described_class.new(data: data, page_info: page_info) } + + describe '#has_next_page?' do + context 'when next page is present' do + it 'returns true' do + expect(subject.has_next_page?).to eq(true) + end + end + + context 'when next page is not present' do + let(:has_next_page) { false } + + it 'returns false' do + expect(subject.has_next_page?).to eq(false) + end + end + end + + describe '#next_page' do + it 'returns next page cursor information' do + expect(subject.next_page).to eq(cursor) + end + end + + describe '#each' do + context 'when block is present' do + it 'yields each data item' do + expect { |b| subject.each(&b) }.to yield_control + end + end + + context 'when block is not present' do + it 'returns enumerator' do + expect(subject.each).to be_instance_of(Enumerator) + end + end + end +end |