Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb')
-rw-r--r--spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb65
1 files changed, 47 insertions, 18 deletions
diff --git a/spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb b/spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb
index aa8243154ef..cbe27934bd5 100644
--- a/spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_issue_event_worker_spec.rb
@@ -5,16 +5,13 @@ require 'spec_helper'
RSpec.describe Gitlab::GithubImport::ImportIssueEventWorker, feature_category: :importers do
subject(:worker) { described_class.new }
- describe '#import' do
- let(:import_state) { create(:import_state, :started) }
-
- let(:project) do
- instance_double('Project', full_path: 'foo/bar', id: 1, import_state: import_state)
+ describe '#execute' do
+ let_it_be(:project) do
+ create(:project, import_url: 'https://github.com/foo/bar.git', import_state: create(:import_state, :started))
end
- let(:client) { instance_double('Gitlab::GithubImport::Client') }
- let(:importer) { instance_double('Gitlab::GithubImport::Importer::IssueEventImporter') }
-
+ let(:client) { instance_double(Gitlab::GithubImport::Client) }
+ let(:extended_events) { true }
let(:event_hash) do
{
'id' => 6501124486,
@@ -29,23 +26,55 @@ RSpec.describe Gitlab::GithubImport::ImportIssueEventWorker, feature_category: :
}
end
- it 'imports an issue event' do
- expect(Gitlab::GithubImport::Importer::IssueEventImporter)
- .to receive(:new)
- .with(
- an_instance_of(Gitlab::GithubImport::Representation::IssueEvent),
- project,
- client
- )
- .and_return(importer)
+ before do
+ allow_next_instance_of(Gitlab::GithubImport::Settings) do |setting|
+ allow(setting).to receive(:extended_events?).and_return(extended_events)
+ end
+ end
- expect(importer).to receive(:execute)
+ it 'imports an issue event and increase importer counter' do
+ expect_next_instance_of(Gitlab::GithubImport::Importer::IssueEventImporter,
+ an_instance_of(Gitlab::GithubImport::Representation::IssueEvent),
+ project,
+ client
+ ) do |importer|
+ expect(importer).to receive(:execute)
+ end
expect(Gitlab::GithubImport::ObjectCounter)
.to receive(:increment)
+ .with(project, :issue_event, :imported)
.and_call_original
worker.import(project, client, event_hash)
end
+
+ context 'when event should increment a mapped importer counter' do
+ before do
+ stub_const('Gitlab::GithubImport::Importer::IssueEventImporter::EVENT_COUNTER_MAP', {
+ 'closed' => 'custom_type'
+ })
+
+ allow_next_instance_of(Gitlab::GithubImport::Importer::IssueEventImporter) do |importer|
+ allow(importer).to receive(:execute)
+ end
+ end
+
+ it 'increments the mapped importer counter' do
+ expect(Gitlab::GithubImport::ObjectCounter).to receive(:increment).with(project, 'custom_type', :imported)
+
+ worker.import(project, client, event_hash)
+ end
+
+ context 'when extended_events is disabled' do
+ let(:extended_events) { false }
+
+ it 'increments the issue_event importer counter' do
+ expect(Gitlab::GithubImport::ObjectCounter).to receive(:increment).with(project, :issue_event, :imported)
+
+ worker.import(project, client, event_hash)
+ end
+ end
+ end
end
end