Commit 7bb01885 authored by Sean McGivern's avatar Sean McGivern

Merge branch '220051-duplicate-issues-created-when-importing-from-csv' into 'master'

Prevent duplicate issues from CSV import when email sending fails

See merge request gitlab-org/gitlab!33626
parents a2deab8f c67f2ec8
...@@ -46,7 +46,7 @@ module Issues ...@@ -46,7 +46,7 @@ module Issues
end end
def email_results_to_user def email_results_to_user
Notify.import_issues_csv_email(@user.id, @project.id, @results).deliver_now Notify.import_issues_csv_email(@user.id, @project.id, @results).deliver_later
end end
def detect_col_sep(header) def detect_col_sep(header)
......
---
title: Prevent duplicate issues when importing from CSV
merge_request: 33626
author:
type: fixed
...@@ -18,9 +18,7 @@ describe Issues::ImportCsvService do ...@@ -18,9 +18,7 @@ describe Issues::ImportCsvService do
let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') }
it 'returns invalid file error' do it 'returns invalid file error' do
expect_next_instance_of(Notify) do |instance| expect(Notify).to receive_message_chain(:import_issues_csv_email, :deliver_later)
expect(instance).to receive(:import_issues_csv_email)
end
expect(subject[:success]).to eq(0) expect(subject[:success]).to eq(0)
expect(subject[:parse_error]).to eq(true) expect(subject[:parse_error]).to eq(true)
...@@ -31,9 +29,7 @@ describe Issues::ImportCsvService do ...@@ -31,9 +29,7 @@ describe Issues::ImportCsvService do
let(:file) { fixture_file_upload('spec/fixtures/csv_gitlab_export.csv') } let(:file) { fixture_file_upload('spec/fixtures/csv_gitlab_export.csv') }
it 'imports the CSV without errors' do it 'imports the CSV without errors' do
expect_next_instance_of(Notify) do |instance| expect(Notify).to receive_message_chain(:import_issues_csv_email, :deliver_later)
expect(instance).to receive(:import_issues_csv_email)
end
expect(subject[:success]).to eq(4) expect(subject[:success]).to eq(4)
expect(subject[:error_lines]).to eq([]) expect(subject[:error_lines]).to eq([])
...@@ -54,9 +50,7 @@ describe Issues::ImportCsvService do ...@@ -54,9 +50,7 @@ describe Issues::ImportCsvService do
let(:file) { fixture_file_upload('spec/fixtures/csv_comma.csv') } let(:file) { fixture_file_upload('spec/fixtures/csv_comma.csv') }
it 'imports CSV without errors' do it 'imports CSV without errors' do
expect_next_instance_of(Notify) do |instance| expect(Notify).to receive_message_chain(:import_issues_csv_email, :deliver_later)
expect(instance).to receive(:import_issues_csv_email)
end
expect(subject[:success]).to eq(3) expect(subject[:success]).to eq(3)
expect(subject[:error_lines]).to eq([]) expect(subject[:error_lines]).to eq([])
...@@ -77,9 +71,7 @@ describe Issues::ImportCsvService do ...@@ -77,9 +71,7 @@ describe Issues::ImportCsvService do
let(:file) { fixture_file_upload('spec/fixtures/csv_tab.csv') } let(:file) { fixture_file_upload('spec/fixtures/csv_tab.csv') }
it 'imports CSV with some error rows' do it 'imports CSV with some error rows' do
expect_next_instance_of(Notify) do |instance| expect(Notify).to receive_message_chain(:import_issues_csv_email, :deliver_later)
expect(instance).to receive(:import_issues_csv_email)
end
expect(subject[:success]).to eq(2) expect(subject[:success]).to eq(2)
expect(subject[:error_lines]).to eq([3]) expect(subject[:error_lines]).to eq([3])
...@@ -100,9 +92,7 @@ describe Issues::ImportCsvService do ...@@ -100,9 +92,7 @@ describe Issues::ImportCsvService do
let(:file) { fixture_file_upload('spec/fixtures/csv_semicolon.csv') } let(:file) { fixture_file_upload('spec/fixtures/csv_semicolon.csv') }
it 'imports CSV with a blank row' do it 'imports CSV with a blank row' do
expect_next_instance_of(Notify) do |instance| expect(Notify).to receive_message_chain(:import_issues_csv_email, :deliver_later)
expect(instance).to receive(:import_issues_csv_email)
end
expect(subject[:success]).to eq(3) expect(subject[:success]).to eq(3)
expect(subject[:error_lines]).to eq([4]) expect(subject[:error_lines]).to eq([4])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment