Defect #4513

MessageObserver: wrong use of compact.uniq??

Added by Anh Kỳ Huỳnh about 2 years ago. Updated about 2 years ago.

Status:Closed Start date:2010-01-02
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Affected version: Resolution:No feedback

Description

In the class MessageObserver, there is a line to compact the list of recipients

recipients = recipients.compact.uniq

The purpose of this line is to make recipients array contains each item once. But I found I still have duplicate items in message_posted (class Mailer). I don't know why so I have to change it:

    parsed = Array.new
    recipients = recipients.select do |m|
      next if parsed.include?(m.user.id)
      send_mail = check_if_user_want_to_receive_mail(m)
      parsed << m.user.id
      send_mail
    end.collect{|m| m.user.mail}

and then I don't have any duplicated items anymore in recipients. I amnot sure but I think this problem is due to Rails/Ruby.

Hope this helps.

My environment: (Redmine 0.8.5)

About your application's environment 

Ruby version              1.8.7 (i686-linux)
RubyGems version          1.3.5
Rails version             2.1.2
Active Record version     2.1.2
Action Pack version       2.1.2
Active Resource version   2.1.2
Action Mailer version     2.1.2
Active Support version    2.1.2
Edge Rails revision       unknown
Application root          /path/to/viettug.org
Environment               development
Database adapter          mysql
Database schema version   101

About your Redmine plugins
Redmine Vote plugin   0.0.2
Blog Plugin           1.1.0

History

Updated by Jean-Philippe Lang about 2 years ago

Please provide a failing test. Also, this code calls an undefined #check_if_user_want_to_receive_mail.

Updated by g b about 2 years ago

  • Status changed from New to Resolved

Updated by Jean-Philippe Lang about 2 years ago

  • Status changed from Resolved to New

Updated by Jean-Philippe Lang about 2 years ago

  • Status changed from New to Closed
  • Resolution set to No feedback

Also available in: Atom PDF