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

releases_attachments_importer_spec.rb « importer « github_import « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1aeb3462cd50bf1e8e4f09d29bb6653ddf66a214 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::GithubImport::Importer::ReleasesAttachmentsImporter do
  subject { described_class.new(project, client) }

  let_it_be(:project) { create(:project) }

  let(:client) { instance_double(Gitlab::GithubImport::Client) }

  describe '#each_object_to_import', :clean_gitlab_redis_cache do
    let!(:release_1) { create(:release, project: project) }
    let!(:release_2) { create(:release, project: project) }

    it 'iterates each project release' do
      list = []
      subject.each_object_to_import do |object|
        list << object
      end
      expect(list).to contain_exactly(release_1, release_2)
    end

    context 'when release is already processed' do
      it "doesn't process this release" do
        subject.mark_as_imported(release_1)

        list = []
        subject.each_object_to_import do |object|
          list << object
        end
        expect(list).to contain_exactly(release_2)
      end
    end
  end

  describe '#representation_class' do
    it { expect(subject.representation_class).to eq(Gitlab::GithubImport::Representation::ReleaseAttachments) }
  end

  describe '#importer_class' do
    it { expect(subject.importer_class).to eq(Gitlab::GithubImport::Importer::ReleaseAttachmentsImporter) }
  end

  describe '#sidekiq_worker_class' do
    it { expect(subject.sidekiq_worker_class).to eq(Gitlab::GithubImport::ImportReleaseAttachmentsWorker) }
  end

  describe '#collection_method' do
    it { expect(subject.collection_method).to eq(:release_attachments) }
  end

  describe '#object_type' do
    it { expect(subject.object_type).to eq(:release_attachment) }
  end

  describe '#id_for_already_imported_cache' do
    let(:release) { build_stubbed(:release) }

    it { expect(subject.id_for_already_imported_cache(release)).to eq(release.id) }
  end

  describe '#object_representation' do
    let(:release) { build_stubbed(:release) }

    it 'returns release attachments representation' do
      representation = subject.object_representation(release)

      expect(representation.class).to eq subject.representation_class
      expect(representation.release_db_id).to eq release.id
      expect(representation.description).to eq release.description
    end
  end
end