diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
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 | 120 |
1 files changed, 41 insertions, 79 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 index 08be350f0f9..c5fa67e50aa 100644 --- 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 @@ -27,100 +27,62 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsReviewsImporter do end describe '#each_object_to_import', :clean_gitlab_redis_cache do - context 'when github_review_importer_query_only_unimported_merge_requests is enabled' do - before do - stub_feature_flags(github_review_importer_query_only_unimported_merge_requests: true) - end - - let(:merge_request) do - create( - :merged_merge_request, - iid: 999, - source_project: project, - target_project: project - ) - end - - let(:review) { double(id: 1) } - - it 'fetches the pull requests reviews data' do - page = double(objects: [review], number: 1) - - expect(review) - .to receive(:merge_request_id=) - .with(merge_request.id) - - expect(client) - .to receive(:each_page) - .exactly(:once) # ensure to be cached on the second call - .with(:pull_request_reviews, 'github/repo', merge_request.iid, page: 1) - .and_yield(page) + let(:merge_request) do + create( + :merged_merge_request, + iid: 999, + source_project: project, + target_project: project + ) + end - expect { |b| subject.each_object_to_import(&b) } - .to yield_with_args(review) + let(:review) { double(id: 1) } - subject.each_object_to_import {} - end + it 'fetches the pull requests reviews data' do + page = double(objects: [review], number: 1) - it 'skips cached pages' do - Gitlab::GithubImport::PageCounter - .new(project, "merge_request/#{merge_request.id}/pull_request_reviews") - .set(2) + expect(review) + .to receive(:merge_request_id=) + .with(merge_request.id) - expect(review).not_to receive(:merge_request_id=) + expect(client) + .to receive(:each_page) + .exactly(:once) # ensure to be cached on the second call + .with(:pull_request_reviews, 'github/repo', merge_request.iid, page: 1) + .and_yield(page) - expect(client) - .to receive(:each_page) - .exactly(:once) # ensure to be cached on the second call - .with(:pull_request_reviews, 'github/repo', merge_request.iid, page: 2) + expect { |b| subject.each_object_to_import(&b) } + .to yield_with_args(review) - subject.each_object_to_import {} - end + subject.each_object_to_import {} + end - it 'skips cached merge requests' do - Gitlab::Cache::Import::Caching.set_add( - "github-importer/merge_request/already-imported/#{project.id}", - merge_request.id - ) + it 'skips cached pages' do + Gitlab::GithubImport::PageCounter + .new(project, "merge_request/#{merge_request.id}/pull_request_reviews") + .set(2) - expect(review).not_to receive(:merge_request_id=) + expect(review).not_to receive(:merge_request_id=) - expect(client).not_to receive(:each_page) + expect(client) + .to receive(:each_page) + .exactly(:once) # ensure to be cached on the second call + .with(:pull_request_reviews, 'github/repo', merge_request.iid, page: 2) - subject.each_object_to_import {} - end + subject.each_object_to_import {} end - context 'when github_review_importer_query_only_unimported_merge_requests is disabled' do - before do - stub_feature_flags(github_review_importer_query_only_unimported_merge_requests: false) - end - - it 'fetchs the merged pull requests data' do - merge_request = create( - :merged_merge_request, - iid: 999, - source_project: project, - target_project: project - ) - - review = double - - expect(review) - .to receive(:merge_request_id=) - .with(merge_request.id) + it 'skips cached merge requests' do + Gitlab::Cache::Import::Caching.set_add( + "github-importer/merge_request/already-imported/#{project.id}", + merge_request.id + ) - allow(client) - .to receive(:pull_request_reviews) - .exactly(:once) # ensure to be cached on the second call - .with('github/repo', merge_request.iid) - .and_return([review]) + expect(review).not_to receive(:merge_request_id=) - expect { |b| subject.each_object_to_import(&b) } - .to yield_with_args(review) + expect(client).not_to receive(:each_page) - subject.each_object_to_import {} - end + subject.each_object_to_import {} end end end |