Project

General

Profile

Patch #4263 ยป only_email_users_who_can_view_issue.diff

Bradly Feeley, 2009-11-22 18:51

View differences:

test/unit/issue_test.rb (working copy)
330 330
    assert_nil copy.custom_value_for(2)
331 331
  end
332 332
  
333
  def test_recipients_of_emails_should_only_be_sent_to_users_that_can_view_the_issue
334
    issue = Issue.find(1)
335
    copy  = issue.move_to(Project.find(3), Tracker.find(2), :copy => true)
336
    #author is not a member of project anymore
337
    assert !copy.recipients.include?(copy.author.mail)
338
  end
339
  
333 340
  def test_issue_destroy
334 341
    Issue.find(1).destroy
335 342
    assert_nil Issue.find_by_id(1)
app/models/issue.rb (working copy)
246 246
  def recipients
247 247
    recipients = project.recipients
248 248
    # Author and assignee are always notified unless they have been locked
249
    recipients << author.mail if author && author.active?
250
    recipients << assigned_to.mail if assigned_to && assigned_to.active?
249
    recipients << author.mail if author && author.active? && author.member_of?(project) && author.allowed_to?(:view_issues, project)
250
    recipients << assigned_to.mail if assigned_to && assigned_to.active? && assigned_to.member_of?(project) && assigned_to.allowed_to?(:view_issues, project)
251 251
    recipients.compact.uniq
252 252
  end
253 253
  
    (1-1/1)