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'