diff options
Diffstat (limited to 'spec/workers/issuable_export_csv_worker_spec.rb')
-rw-r--r-- | spec/workers/issuable_export_csv_worker_spec.rb | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/spec/workers/issuable_export_csv_worker_spec.rb b/spec/workers/issuable_export_csv_worker_spec.rb index a5172d916b6..66198157edb 100644 --- a/spec/workers/issuable_export_csv_worker_spec.rb +++ b/spec/workers/issuable_export_csv_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe IssuableExportCsvWorker do +RSpec.describe IssuableExportCsvWorker, feature_category: :team_planning do let(:user) { create(:user) } let(:project) { create(:project, creator: user) } let(:params) { {} } @@ -50,6 +50,19 @@ RSpec.describe IssuableExportCsvWorker do end end + shared_examples 'export with selected fields' do + let(:selected_fields) { %w[Title Description'] } + + it 'calls the export service with selected fields' do + params[:selected_fields] = selected_fields + + expect(export_service) + .to receive(:new).with(anything, project, selected_fields).once.and_call_original + + subject + end + end + context 'when issuable type is MergeRequest' do let(:issuable_type) { :merge_request } @@ -58,7 +71,7 @@ RSpec.describe IssuableExportCsvWorker do end it 'calls the MR export service' do - expect(MergeRequests::ExportCsvService).to receive(:new).with(anything, project).once.and_call_original + expect(MergeRequests::ExportCsvService).to receive(:new).with(anything, project, []).once.and_call_original subject end @@ -68,6 +81,34 @@ RSpec.describe IssuableExportCsvWorker do subject end + + it_behaves_like 'export with selected fields' do + let(:export_service) { MergeRequests::ExportCsvService } + end + end + + context 'for type WorkItem' do + let(:issuable_type) { :work_item } + + it 'emails a CSV' do + expect { subject }.to change { ActionMailer::Base.deliveries.size }.by(1) + end + + it 'calls the work item export service' do + expect(WorkItems::ExportCsvService).to receive(:new).with(anything, project, []).once.and_call_original + + subject + end + + it 'calls the WorkItemsFinder' do + expect(WorkItems::WorkItemsFinder).to receive(:new).once.and_call_original + + subject + end + + it_behaves_like 'export with selected fields' do + let(:export_service) { WorkItems::ExportCsvService } + end end context 'when issuable type is User' do |