diff options
Diffstat (limited to 'spec/views/notify')
5 files changed, 116 insertions, 4 deletions
diff --git a/spec/views/notify/approved_merge_request_email.html.haml_spec.rb b/spec/views/notify/approved_merge_request_email.html.haml_spec.rb new file mode 100644 index 00000000000..7d19e628eb8 --- /dev/null +++ b/spec/views/notify/approved_merge_request_email.html.haml_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'email_spec' + +RSpec.describe 'notify/approved_merge_request_email.html.haml' do + let(:user) { create(:user) } + let(:merge_request) { create(:merge_request) } + let(:group) { create(:group) } + let(:project) { create(:project, group: group) } + + before do + allow(view).to receive(:message) { instance_double(Mail::Message, subject: 'Subject') } + assign(:project, project) + assign(:approved_by, user) + assign(:merge_request, merge_request) + end + + it 'contains approval information' do + render + + expect(rendered).to have_content(merge_request.to_reference.to_s) + expect(rendered).to have_content("was approved by") + expect(rendered).to have_content(user.name.to_s) + end +end diff --git a/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb index c3cb0c83f35..d8299d637e1 100644 --- a/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb +++ b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'notify/autodevops_disabled_email.text.erb' do expect(rendered).to have_content("Auto DevOps pipeline was disabled for #{project.name}") expect(rendered).to match(/Pipeline ##{pipeline.id} .* triggered by #{pipeline.user.name}/) - expect(rendered).to have_content("Stage: #{build.stage}") + expect(rendered).to have_content("Stage: #{build.stage_name}") expect(rendered).to have_content("Name: #{build.name}") expect(rendered).not_to have_content("Trace:") end diff --git a/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb b/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb index 6d56145144f..deef13fec99 100644 --- a/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb +++ b/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb @@ -12,10 +12,25 @@ RSpec.describe 'notify/change_in_merge_request_draft_status_email.html.haml' do assign(:merge_request, merge_request) end + it 'shows user added draft status on email' do + merge_request.update!(title: merge_request.draft_title) + + render + + expect(merge_request.draft).to be_truthy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as draft") + end + + it 'shows user removed draft status on email' do + render + + expect(merge_request.draft).to be_falsy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as ready") + end + it 'renders the email correctly' do render - expect(rendered).to have_content("#{user.name} changed the draft status of merge request #{merge_request.to_reference}") expect(rendered).to have_link(user.name, href: user_url(user)) expect(rendered).to have_link(merge_request.to_reference, href: merge_request_link) end diff --git a/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb b/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb index a05c20fd8c4..3faba483516 100644 --- a/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb +++ b/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb @@ -12,9 +12,19 @@ RSpec.describe 'notify/change_in_merge_request_draft_status_email.text.erb' do it_behaves_like 'renders plain text email correctly' - it 'renders the email correctly' do + it 'shows user added draft status on email' do + merge_request.update!(title: merge_request.draft_title) + + render + + expect(merge_request.draft).to be_truthy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as draft") + end + + it 'shows user removed draft status on email' do render - expect(rendered).to have_content("#{user.name} changed the draft status of merge request #{merge_request.to_reference}") + expect(merge_request.draft).to be_falsy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as ready") end end 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 |