2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe ImportIssuesCsvWorker do
|
2021-02-22 17:27:13 +05:30
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
let(:upload) { create(:upload, :with_file) }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
it 'calls #execute on Issues::ImportCsvService and destroys upload' do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect_next_instance_of(Issues::ImportCsvService) do |instance|
|
|
|
|
expect(instance).to receive(:execute).and_return({ success: 5, errors: [], valid_file: true })
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
worker.perform(user.id, project.id, upload.id)
|
|
|
|
|
|
|
|
expect { upload.reload }.to raise_error ActiveRecord::RecordNotFound
|
|
|
|
end
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
it_behaves_like 'an idempotent worker' do
|
|
|
|
let(:job_args) { [user.id, project.id, upload.id] }
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|