rosa-build/spec/mailers/user_mailer_spec.rb

98 lines
3.0 KiB
Ruby
Raw Permalink Normal View History

2011-03-10 21:48:15 +00:00
require "spec_helper"
describe UserMailer do
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! }
before do
stub_symlink_methods
2015-06-05 19:56:39 +01:00
allow(User).to receive(:find) { issue_user }
allow(Issue).to receive(:find) { issue }
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})"
end
it 'should render receiver email' do
2015-06-05 19:56:39 +01:00
expect(email.to).to eq [issue_user.email]
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']]
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)
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)
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! }
2015-06-05 19:56:39 +01:00
before do
stub_symlink_methods
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})"
end
it 'should render receiver email' do
2015-06-05 19:56:39 +01:00
expect(email.to).to eq [user.email]
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']]
end
it 'should assign issue title' do
2015-06-05 19:56:39 +01:00
expect(email.body.encoded).to match(issue.title)
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! }
before do
stub_symlink_methods
2015-06-05 19:56:39 +01:00
allow(User).to receive(:find) { issue_user }
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})"
end
it 'should render receiver email' do
2015-06-05 19:56:39 +01:00
expect(email.to).to eq [issue_user.email]
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']]
end
it 'should assign comment body' do
2015-06-05 19:56:39 +01:00
expect(email.body.encoded).to match(comment.body)
end
end
2011-03-10 21:48:15 +00:00
end