Merge pull request #835 from warpc/829-fix_issue_notifications

[refs #829] Prevent send notification email for issues creator
This commit is contained in:
Vladimir Sharshov 2013-01-15 03:20:10 -08:00
commit 02f50b845c
2 changed files with 19 additions and 1 deletions

View File

@ -13,6 +13,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
when 'Issue'
record.collect_recipients.each do |recipient|
next if record.user_id == recipient.id
UserMailer.new_issue_notification(record, recipient).deliver if recipient.notifier.can_notify && recipient.notifier.new_issue
ActivityFeed.create(
:user => recipient,

View File

@ -21,13 +21,18 @@ describe Issue do
before(:each) do
set_data
@project = FactoryGirl.create(:project, :owner => @user)
create_issue(@stranger)
end
it 'should send an e-mail' do
create_issue(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
end
it 'should not send an e-mail to creator' do
create_issue(@user)
ActionMailer::Base.deliveries.count.should == 0
end
end
context 'for member-group' do
@ -47,6 +52,13 @@ describe Issue do
ActionMailer::Base.deliveries.count.should == 3 # 1 owner + 2 group member. enough?
end
it 'should send an e-mail to all members of the admin group except creator' do
@project.relations.create!(:actor_type => 'Group', :actor_id => @group.id, :role => 'admin')
create_issue(@group.owner)
ActionMailer::Base.deliveries.count.should == 2 # 1 owner + 1 group member. enough?
end
it 'should not send an e-mail to members of the reader group' do
@project.relations.create!(:actor_type => 'Group', :actor_id => @group.id, :role => 'reader')
@ -68,6 +80,11 @@ describe Issue do
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
end
it 'should not send an e-mail to creator' do
create_issue(@user)
ActionMailer::Base.deliveries.count.should == 0
end
end
context 'for reader of the group' do