Commit 0371858b authored by Rémy Coutable's avatar Rémy Coutable

Add tests for the service desk emails

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent c077a9bd
......@@ -11,13 +11,13 @@ module Emails
def service_desk_thank_you_email(issue_id)
setup_service_desk_mail(issue_id)
mail_new_thread(@issue, service_desk_options(@support_bot.id))
mail_new_thread(@issue, service_desk_options(@support_bot.id).merge(subject: "Re: #{@issue.title} (##{@issue.iid})"))
end
def service_desk_new_note_email(issue_id, note_id)
@note = Note.find(note_id)
setup_service_desk_mail(issue_id)
mail_answer_thread(@issue, service_desk_options(@note.author_id))
mail_answer_thread(@issue, service_desk_options(@note.author_id).merge(subject: "#{@issue.title} (##{@issue.iid})"))
end
private
......@@ -33,8 +33,7 @@ module Emails
def service_desk_options(author_id)
{
from: sender(author_id),
to: @issue.service_desk_reply_to,
subject: "Re: #{@issue.title} (##{@issue.iid})"
to: @issue.service_desk_reply_to
}
end
end
......
......@@ -4,6 +4,7 @@ require 'email_spec'
describe Notify do
include EmailSpec::Helpers
include EmailSpec::Matchers
include EmailHelpers
include RepoHelpers
include_context 'gitlab email notification'
......@@ -20,6 +21,13 @@ describe Notify do
description: 'Awesome description')
end
set(:issue) do
create(:issue, author: current_user,
assignees: [assignee],
project: project,
description: 'My awesome description!')
end
set(:project2) { create(:project, :repository) }
set(:merge_request_without_assignee) do
create(:merge_request, source_project: project2,
......@@ -28,6 +36,36 @@ describe Notify do
end
context 'for a project' do
context 'for service desk issues' do
describe 'thank you email' do
subject { described_class.service_desk_thank_you_email(issue.id) }
it_behaves_like 'an unsubscribeable thread'
it 'has the correct subject and body' do
aggregate_failures do
is_expected.to have_referable_subject(issue, include_project: false, reply: true)
is_expected.to have_body_text("Thank you for your support request! We are tracking your request as ticket #{issue.to_reference}, and will respond as soon as we can.")
end
end
end
describe 'new note email' do
set(:first_note) { create(:discussion_note_on_issue, note: 'Hello world') }
subject { described_class.service_desk_new_note_email(issue.id, first_note.id) }
it_behaves_like 'an unsubscribeable thread'
it 'has the correct subject and body' do
aggregate_failures do
is_expected.to have_referable_subject(issue, include_project: false, reply: true)
is_expected.to have_body_text(first_note.note)
end
end
end
end
context 'for merge requests' do
describe "that are new with approver" do
before do
......
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