2011-03-10 21:48:15 +00:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe UserMailer do
|
2012-01-11 07:12:23 +00:00
|
|
|
|
|
|
|
context 'On Issue create' do
|
2015-06-05 19:56:39 +01:00
|
|
|
let(:project) { FactoryGirl.build(:project) }
|
|
|
|
let(:issue_user) { FactoryGirl.build(:user) }
|
|
|
|
let(:issue) { FactoryGirl.build(:issue, project: project, assignee: issue_user, user: issue_user) }
|
|
|
|
let(:email) { UserMailer.new_issue_notification(issue.id, issue_user.id).deliver! }
|
|
|
|
|
2014-03-14 22:54:04 +00:00
|
|
|
before do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2015-06-05 19:56:39 +01:00
|
|
|
allow(User).to receive(:find) { issue_user }
|
|
|
|
allow(Issue).to receive(:find) { issue }
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.subject).to eq "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.to).to eq [issue_user.email]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.from).to eq [APP_CONFIG['do-not-reply-email']]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue project name' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.body.encoded).to match(issue.project.name)
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
2013-03-19 12:42:04 +00:00
|
|
|
it 'should assign issue body' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.body.encoded).to match(issue.body)
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'On Issue assign' do
|
2015-06-05 19:56:39 +01:00
|
|
|
let(:project) { FactoryGirl.build(:project) }
|
|
|
|
let(:issue_user) { FactoryGirl.build(:user) }
|
|
|
|
let(:user) { FactoryGirl.build(:user) }
|
|
|
|
let(:issue) { FactoryGirl.build(:issue, project: project, assignee: issue_user, user: issue_user) }
|
|
|
|
let(:email) { UserMailer.issue_assign_notification(issue, user).deliver! }
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2015-06-05 19:56:39 +01:00
|
|
|
before do
|
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.subject).to eq "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.to).to eq [user.email]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.from).to eq [APP_CONFIG['do-not-reply-email']]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue title' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.body.encoded).to match(issue.title)
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'On Comment create' do
|
2015-06-05 19:56:39 +01:00
|
|
|
let(:project) { FactoryGirl.build(:project) }
|
|
|
|
let(:issue_user) { FactoryGirl.build(:user) }
|
|
|
|
let(:user) { FactoryGirl.build(:user) }
|
|
|
|
let(:issue) { FactoryGirl.build(:issue, project: project, assignee: issue_user, user: issue_user) }
|
|
|
|
let(:comment) { FactoryGirl.build(:comment, commentable: issue, user: user, project: project) }
|
|
|
|
let(:email) { UserMailer.new_comment_notification(comment, issue_user.id).deliver! }
|
|
|
|
|
2014-03-14 22:54:04 +00:00
|
|
|
before do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2015-06-05 19:56:39 +01:00
|
|
|
allow(User).to receive(:find) { issue_user }
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.subject).to eq "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.to).to eq [issue_user.email]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.from).to eq [APP_CONFIG['do-not-reply-email']]
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign comment body' do
|
2015-06-05 19:56:39 +01:00
|
|
|
expect(email.body.encoded).to match(comment.body)
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
end
|
2011-03-10 21:48:15 +00:00
|
|
|
end
|