diff options
Diffstat (limited to 'spec/support/services')
-rw-r--r-- | spec/support/services/issuable_import_csv_service_shared_examples.rb | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/support/services/issuable_import_csv_service_shared_examples.rb b/spec/support/services/issuable_import_csv_service_shared_examples.rb index 20ac2ff5c7c..f68750bec32 100644 --- a/spec/support/services/issuable_import_csv_service_shared_examples.rb +++ b/spec/support/services/issuable_import_csv_service_shared_examples.rb @@ -26,29 +26,33 @@ RSpec.shared_examples 'issuable import csv service' do |issuable_type| end end + shared_examples_for 'invalid file' do + it 'returns invalid file error' do + expect(subject[:success]).to eq(0) + expect(subject[:parse_error]).to eq(true) + end + + it_behaves_like 'importer with email notification' + it_behaves_like 'an issuable importer' + end + describe '#execute' do - context 'invalid file' do + context 'invalid file extension' do let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } - it 'returns invalid file error' do - expect(subject[:success]).to eq(0) - expect(subject[:parse_error]).to eq(true) - end + it_behaves_like 'invalid file' + end - it_behaves_like 'importer with email notification' - it_behaves_like 'an issuable importer' + context 'empty file' do + let(:file) { fixture_file_upload('spec/fixtures/csv_empty.csv') } + + it_behaves_like 'invalid file' end context 'file without headers' do let(:file) { fixture_file_upload('spec/fixtures/csv_no_headers.csv') } - it 'returns invalid file error' do - expect(subject[:success]).to eq(0) - expect(subject[:parse_error]).to eq(true) - end - - it_behaves_like 'importer with email notification' - it_behaves_like 'an issuable importer' + it_behaves_like 'invalid file' end context 'with a file generated by Gitlab CSV export' do |