@@ -250,13 +250,23 class Issue < ActiveRecord::Base | |||
|
250 | 250 | blocked? ? statuses.reject {|s| s.is_closed?} : statuses |
|
251 | 251 | end |
|
252 | 252 | |
|
253 |
# Returns the mail adresses of users that should be notified |
|
|
253 | # Returns the mail adresses of users that should be notified | |
|
254 | 254 | def recipients |
|
255 |
|
|
|
255 | notified = project.notified_users | |
|
256 | 256 | # Author and assignee are always notified unless they have been locked |
|
257 |
|
|
|
258 |
|
|
|
259 | recipients.compact.uniq | |
|
257 | notified << author if author && author.active? | |
|
258 | notified << assigned_to if assigned_to && assigned_to.active? | |
|
259 | notified.uniq! | |
|
260 | # Remove users that can not view the issue | |
|
261 | notified.reject! {|user| !visible?(user)} | |
|
262 | notified.collect(&:mail) | |
|
263 | end | |
|
264 | ||
|
265 | # Returns the mail adresses of watchers that should be notified | |
|
266 | def watcher_recipients | |
|
267 | notified = watcher_users | |
|
268 | notified.reject! {|user| !user.active? || !visible?(user)} | |
|
269 | notified.collect(&:mail) | |
|
260 | 270 | end |
|
261 | 271 | |
|
262 | 272 | # Returns the total number of hours spent on this issue. |
@@ -352,6 +352,11 class Project < ActiveRecord::Base | |||
|
352 | 352 | members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user.mail} |
|
353 | 353 | end |
|
354 | 354 | |
|
355 | # Returns the users that should be notified on project events | |
|
356 | def notified_users | |
|
357 | members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user} | |
|
358 | end | |
|
359 | ||
|
355 | 360 | # Returns an array of all custom fields enabled for project issues |
|
356 | 361 | # (explictly associated custom fields and custom fields enabled for all projects) |
|
357 | 362 | def all_issue_custom_fields |
@@ -185,7 +185,7 issues_012: | |||
|
185 | 185 | description: |
|
186 | 186 | tracker_id: 1 |
|
187 | 187 | assigned_to_id: |
|
188 |
author_id: |
|
|
188 | author_id: 3 | |
|
189 | 189 | status_id: 5 |
|
190 | 190 | start_date: <%= 1.day.ago.to_date.to_s(:db) %> |
|
191 | 191 | due_date: |
@@ -353,6 +353,23 class IssueTest < ActiveSupport::TestCase | |||
|
353 | 353 | assert_nil copy.custom_value_for(2) |
|
354 | 354 | end |
|
355 | 355 | |
|
356 | def test_recipients_should_not_include_users_that_cannot_view_the_issue | |
|
357 | issue = Issue.find(12) | |
|
358 | assert issue.recipients.include?(issue.author.mail) | |
|
359 | # move the issue to a private project | |
|
360 | copy = issue.move_to(Project.find(5), Tracker.find(2), :copy => true) | |
|
361 | # author is not a member of project anymore | |
|
362 | assert !copy.recipients.include?(copy.author.mail) | |
|
363 | end | |
|
364 | ||
|
365 | def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue | |
|
366 | user = User.find(3) | |
|
367 | issue = Issue.find(9) | |
|
368 | Watcher.create!(:user => user, :watchable => issue) | |
|
369 | assert issue.watched_by?(user) | |
|
370 | assert !issue.watcher_recipients.include?(user.mail) | |
|
371 | end | |
|
372 | ||
|
356 | 373 | def test_issue_destroy |
|
357 | 374 | Issue.find(1).destroy |
|
358 | 375 | assert_nil Issue.find_by_id(1) |
General Comments 0
You need to be logged in to leave comments.
Login now