From 265e52bb80bda8bb5c894a69716d795620fd27a3 Mon Sep 17 00:00:00 2001 From: John Kristensen Date: Fri, 14 Jun 2019 06:17:51 +0000 Subject: [PATCH] Improve the gitea importer test The changes to the tests to support ignoring Gitea pull requests comments were a bit of a hack. The suggestions provided by Ash McKenzie in gitlab-org/gitlab-ce!29521 make things a bit more flexible if any future changes need to be made to the tests. The changes made to ignore --- .../legacy_github_import/importer_spec.rb | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/spec/lib/gitlab/legacy_github_import/importer_spec.rb b/spec/lib/gitlab/legacy_github_import/importer_spec.rb index 70a09c4bdc5..a0c664da185 100644 --- a/spec/lib/gitlab/legacy_github_import/importer_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/importer_spec.rb @@ -13,27 +13,22 @@ describe Gitlab::LegacyGithubImport::Importer do expected_called = [ :import_labels, :import_milestones, :import_pull_requests, :import_issues, - :import_wiki, :import_releases, :handle_errors + :import_wiki, :import_releases, :handle_errors, + [:import_comments, :issues], + [:import_comments, :pull_requests] ] expected_called -= expected_not_called aggregate_failures do - expected_called.each do |method_name| - expect(importer).to receive(method_name) + expected_called.each do |method_name, arg| + base_expectation = proc { expect(importer).to receive(method_name) } + arg ? base_expectation.call.with(arg) : base_expectation.call end - expect(importer).to receive(:import_comments).with(:issues) - - if expected_not_called.include? :import_comments_pull_requests - expect(importer).not_to receive(:import_comments).with(:pull_requests) - expected_not_called.delete_at expected_not_called.index :import_comments_pull_requests - else - expect(importer).to receive(:import_comments).with(:pull_requests) - end - - expected_not_called.each do |method_name| - expect(importer).not_to receive(method_name) + expected_not_called.each do |method_name, arg| + base_expectation = proc { expect(importer).not_to receive(method_name) } + arg ? base_expectation.call.with(arg) : base_expectation.call end end @@ -295,7 +290,7 @@ describe Gitlab::LegacyGithubImport::Importer do end it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute' do - let(:expected_not_called) { [:import_releases, :import_comments_pull_requests] } + let(:expected_not_called) { [:import_releases, [:import_comments, :pull_requests]] } end it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute an error occurs' it_behaves_like 'Gitlab::LegacyGithubImport unit-testing'