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
|
|
|
|
before(:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@project = FactoryGirl.create(:project)
|
|
|
|
@issue_user = FactoryGirl.create(:user)
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
@issue = FactoryGirl.create(:issue, project_id: @project.id, assignee_id: @issue_user.id, user: @issue_user)
|
2013-07-24 15:04:10 +01:00
|
|
|
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver!
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2013-03-19 11:20:04 +00:00
|
|
|
@email.subject.should == "[#{@issue.project.name}] #{@issue.title} (##{@issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
|
|
|
@email.to.should == [@issue_user.email]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
|
|
|
@email.from.should == [APP_CONFIG['do-not-reply-email']]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue project name' do
|
|
|
|
@email.body.encoded.should match(@issue.project.name)
|
|
|
|
end
|
|
|
|
|
2013-03-19 12:42:04 +00:00
|
|
|
it 'should assign issue body' do
|
2013-03-19 11:20:04 +00:00
|
|
|
@email.body.encoded.should match(@issue.body)
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'On Issue assign' do
|
|
|
|
before(:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@project = FactoryGirl.create(:project)
|
|
|
|
@issue_user = FactoryGirl.create(:user)
|
|
|
|
@user = FactoryGirl.create(:user)
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
@issue = FactoryGirl.create(:issue, project_id: @project.id, assignee_id: @issue_user.id, user: @issue_user)
|
2013-07-24 15:04:10 +01:00
|
|
|
@email = UserMailer.issue_assign_notification(@issue, @user).deliver!
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2013-03-19 11:20:04 +00:00
|
|
|
@email.subject.should == "Re: [#{@issue.project.name}] #{@issue.title} (##{@issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
|
|
|
@email.to.should == [@user.email]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
|
|
|
@email.from.should == [APP_CONFIG['do-not-reply-email']]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue title' do
|
|
|
|
@email.body.encoded.should match(@issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'On Comment create' do
|
|
|
|
before(:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@project = FactoryGirl.create(:project)
|
|
|
|
@issue_user = FactoryGirl.create(:user)
|
|
|
|
@user = FactoryGirl.create(:user)
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
|
2012-01-11 07:12:23 +00:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
@issue = FactoryGirl.create(:issue, project_id: @project.id, assignee_id: @issue_user.id, user: @issue_user)
|
|
|
|
@comment = FactoryGirl.create(:comment, commentable: @issue, user_id: @user.id, project: @project)
|
2013-07-24 15:04:10 +01:00
|
|
|
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver!
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
2013-03-19 11:20:04 +00:00
|
|
|
@email.subject.should == "Re: [#{@issue.project.name}] #{@issue.title} (##{@issue.serial_id})"
|
2012-01-11 07:12:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render receiver email' do
|
|
|
|
@email.to.should == [@issue_user.email]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render the sender email' do
|
|
|
|
@email.from.should == [APP_CONFIG['do-not-reply-email']]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign comment body' do
|
|
|
|
@email.body.encoded.should match(@comment.body)
|
|
|
|
end
|
|
|
|
end
|
2011-03-10 21:48:15 +00:00
|
|
|
end
|