2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-03-10 21:48:15 +00:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe UserMailer do
|
|
|
|
pending "add some examples to (or delete) #{__FILE__}"
|
2012-01-11 07:12:23 +00:00
|
|
|
|
|
|
|
context 'On Issue create' do
|
|
|
|
before(:each) do
|
|
|
|
stub_rsync_methods
|
|
|
|
|
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
|
|
|
|
|
|
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
2012-01-11 07:12:23 +00:00
|
|
|
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
|
|
|
@email.subject.should == I18n.t("notifications.subjects.new_issue_notification")
|
|
|
|
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 user name' do
|
|
|
|
@email.body.encoded.should match(@issue_user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue project name' do
|
|
|
|
@email.body.encoded.should match(@issue.project.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue title' do
|
|
|
|
@email.body.encoded.should match(@issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'On Issue assign' do
|
|
|
|
before(:each) do
|
|
|
|
stub_rsync_methods
|
|
|
|
|
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
|
|
|
|
|
|
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
2012-01-11 07:12:23 +00:00
|
|
|
@email = UserMailer.issue_assign_notification(@issue, @user).deliver
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
|
|
|
@email.subject.should == I18n.t("notifications.subjects.issue_assign_notification")
|
|
|
|
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 user name' do
|
|
|
|
@email.body.encoded.should match(@user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue title' do
|
|
|
|
@email.body.encoded.should match(@issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'On Comment create' do
|
|
|
|
before(:each) do
|
|
|
|
stub_rsync_methods
|
|
|
|
|
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
|
|
|
|
|
|
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
|
|
|
@comment = FactoryGirl.create(:comment, :commentable => @issue, :user_id => @user.id, :project => @project)
|
2012-01-11 07:12:23 +00:00
|
|
|
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct subject' do
|
|
|
|
@email.subject.should == I18n.t("notifications.subjects.new_comment_notification")
|
|
|
|
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 user name' do
|
|
|
|
@email.body.encoded.should match(@issue_user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign comment body' do
|
|
|
|
@email.body.encoded.should match(@comment.body)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should assign issue title' do
|
|
|
|
@email.body.encoded.should match(@issue.title)
|
|
|
|
end
|
|
|
|
end
|
2011-03-10 21:48:15 +00:00
|
|
|
end
|