summaryrefslogtreecommitdiff
path: root/spec/workers/projects/import_export/relation_export_worker_spec.rb
blob: 236650fe55bb3bc315bd2b6fdf2330d51f2a795e (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker do
  let(:project_relation_export) { create(:project_relation_export) }
  let(:job_args) { [project_relation_export.id] }

  it_behaves_like 'an idempotent worker'

  describe '#perform' do
    subject(:worker) { described_class.new }

    context 'when relation export has initial state queued' do
      let(:project_relation_export) { create(:project_relation_export) }

      it 'calls RelationExportService' do
        expect_next_instance_of(Projects::ImportExport::RelationExportService) do |service|
          expect(service).to receive(:execute)
        end

        worker.perform(project_relation_export.id)
      end
    end

    context 'when relation export does not have queued state' do
      let(:project_relation_export) { create(:project_relation_export, status_event: :start) }

      it 'does not call RelationExportService' do
        expect(Projects::ImportExport::RelationExportService).not_to receive(:new)

        worker.perform(project_relation_export.id)
      end
    end
  end
end