diff options
Diffstat (limited to 'spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb new file mode 100644 index 00000000000..5e2302f9662 --- /dev/null +++ b/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::GithubImport::Importer::PullRequestsReviewsImporter do + let(:client) { double } + let(:project) { create(:project, import_source: 'github/repo') } + + subject { described_class.new(project, client) } + + it { is_expected.to include_module(Gitlab::GithubImport::ParallelScheduling) } + + describe '#representation_class' do + it { expect(subject.representation_class).to eq(Gitlab::GithubImport::Representation::PullRequestReview) } + end + + describe '#importer_class' do + it { expect(subject.importer_class).to eq(Gitlab::GithubImport::Importer::PullRequestReviewImporter) } + end + + describe '#collection_method' do + it { expect(subject.collection_method).to eq(:pull_request_reviews) } + end + + describe '#id_for_already_imported_cache' do + it { expect(subject.id_for_already_imported_cache(double(github_id: 1))).to eq(1) } + end + + describe '#each_object_to_import' do + it 'fetchs the merged pull requests data' do + merge_request = create(:merge_request, source_project: project) + review = double + + expect(review) + .to receive(:merge_request_id=) + .with(merge_request.id) + + allow(client) + .to receive(:pull_request_reviews) + .with('github/repo', merge_request.iid) + .and_return([review]) + + expect { |b| subject.each_object_to_import(&b) }.to yield_with_args(review) + end + end +end |