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
|
2019-02-15 15:39:39 +05:30
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:upload) { create(:upload) }
|
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|