blob: c1c19c40afb859e24dd065139cd74414ce879538 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GithubImport::Importer::Attachments::ReleasesImporter, feature_category: :importers do
subject(:importer) { described_class.new(project, client) }
let_it_be(:project) { create(:project) }
let(:client) { instance_double(Gitlab::GithubImport::Client) }
describe '#sequential_import', :clean_gitlab_redis_cache do
let_it_be(:release_1) { create(:release, project: project) }
let_it_be(:release_2) { create(:release, project: project) }
let(:importer_stub) { instance_double('Gitlab::GithubImport::Importer::NoteAttachmentsImporter') }
let(:importer_attrs) { [instance_of(Gitlab::GithubImport::Representation::NoteText), project, client] }
it 'imports each project release' do
expect(project.releases).to receive(:id_not_in).with([]).and_return(project.releases)
expect(project.releases).to receive(:select).with(:id, :description, :tag).and_call_original
expect(Gitlab::GithubImport::Importer::NoteAttachmentsImporter).to receive(:new)
.with(*importer_attrs).twice.and_return(importer_stub)
expect(importer_stub).to receive(:execute).twice
importer.sequential_import
end
context 'when note is already processed' do
it "doesn't import this release" do
importer.mark_as_imported(release_1)
expect(project.releases).to receive(:id_not_in).with([release_1.id.to_s]).and_call_original
expect(Gitlab::GithubImport::Importer::NoteAttachmentsImporter).to receive(:new)
.with(*importer_attrs).once.and_return(importer_stub)
expect(importer_stub).to receive(:execute).once
importer.sequential_import
end
end
end
describe '#sidekiq_worker_class' do
it { expect(importer.sidekiq_worker_class).to eq(Gitlab::GithubImport::Attachments::ImportReleaseWorker) }
end
describe '#collection_method' do
it { expect(importer.collection_method).to eq(:release_attachments) }
end
describe '#object_type' do
it { expect(importer.object_type).to eq(:release_attachment) }
end
describe '#id_for_already_imported_cache' do
let(:release) { build_stubbed(:release) }
it { expect(importer.id_for_already_imported_cache(release)).to eq(release.id) }
end
end
|