rosa-build/spec/mailers/user_mailer_spec.rb

103 lines
2.9 KiB
Ruby
Raw Normal View History

2011-03-10 21:48:15 +00:00
require "spec_helper"
describe UserMailer do
context 'On Issue create' do
before do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue_user = FactoryGirl.create(:user)
2014-01-21 04:51:49 +00:00
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
@issue = FactoryGirl.create(:issue, project: @project, assignee: @issue_user, user: @issue_user)
2013-07-24 15:04:10 +01:00
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver!
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})"
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)
end
end
context 'On Issue assign' do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue_user = FactoryGirl.create(:user)
@user = FactoryGirl.create(:user)
2014-01-21 04:51:49 +00:00
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
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!
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})"
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 do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue_user = FactoryGirl.create(:user)
@user = FactoryGirl.create(:user)
2014-01-21 04:51:49 +00:00
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
@issue = FactoryGirl.create(:issue, project: @project, assignee: @issue_user, user: @issue_user)
@comment = FactoryGirl.create(:comment, commentable: @issue, user: @user, project: @project)
2013-07-24 15:04:10 +01:00
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver!
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})"
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