summaryrefslogtreecommitdiff
path: root/spec/views/notify/import_issues_csv_email.html.haml_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 23:18:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 23:18:09 +0000
commit6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch)
treedc4d20fe6064752c0bd323187252c77e0a89144b /spec/views/notify/import_issues_csv_email.html.haml_spec.rb
parent9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff)
downloadgitlab-ce-6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde.tar.gz
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/views/notify/import_issues_csv_email.html.haml_spec.rb')
-rw-r--r--spec/views/notify/import_issues_csv_email.html.haml_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/views/notify/import_issues_csv_email.html.haml_spec.rb b/spec/views/notify/import_issues_csv_email.html.haml_spec.rb
new file mode 100644
index 00000000000..43dfab87ac9
--- /dev/null
+++ b/spec/views/notify/import_issues_csv_email.html.haml_spec.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'notify/import_issues_csv_email.html.haml' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+ let(:correct_results) { { success: 3, valid_file: true } }
+ let(:errored_results) { { success: 3, error_lines: [5, 6, 7], valid_file: true } }
+ let(:parse_error_results) { { success: 0, parse_error: true } }
+
+ before do
+ assign(:user, user)
+ assign(:project, project)
+ end
+
+ context 'when no errors found while importing' do
+ before do
+ assign(:results, correct_results)
+ end
+
+ it 'renders correctly' do
+ render
+
+ expect(rendered).to have_link(project.full_name, href: project_url(project))
+ expect(rendered).to have_content("3 issues imported")
+ expect(rendered).not_to have_content("Errors found on line")
+ expect(rendered).not_to have_content(
+ "Error parsing CSV file. Please make sure it has the correct format: \
+a delimited text file that uses a comma to separate values.")
+ end
+ end
+
+ context 'when import errors reported' do
+ before do
+ assign(:results, errored_results)
+ end
+
+ it 'renders correctly' do
+ render
+
+ expect(rendered).to have_content("Errors found on lines: #{errored_results[:error_lines].join(", ")}. \
+Please check if these lines have an issue title.")
+ expect(rendered).not_to have_content("Error parsing CSV file. Please make sure it has the correct format: \
+a delimited text file that uses a comma to separate values.")
+ end
+ end
+
+ context 'when parse error reported while importing' do
+ before do
+ assign(:results, parse_error_results)
+ end
+
+ it 'renders with parse error' do
+ render
+
+ expect(rendered).to have_content("Error parsing CSV file. \
+Please make sure it has the correct format: a delimited text file that uses a comma to separate values.")
+ end
+ end
+end