From cdb86d5ef7d21090e9ee8f58597a2ccc190b6818 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 3 Mar 2010 21:32:41 +0000 Subject: [PATCH] Fixed: no email notification on new project/version file added (#4966). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3532 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 4 ++-- test/unit/mailer_test.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 1834a7f8..173e33c4 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -114,11 +114,11 @@ class Mailer < ActionMailer::Base when 'Project' added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container) added_to = "#{l(:label_project)}: #{container}" - recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)} + recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail} when 'Version' added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container.project_id) added_to = "#{l(:label_version)}: #{container.name}" - recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)} + recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail} when 'Document' added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id) added_to = "#{l(:label_document)}: #{container.title}" diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 8850f823..68b074a9 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -273,6 +273,20 @@ class MailerTest < ActiveSupport::TestCase end end + def test_version_file_added + attachements = [ Attachment.find_by_container_type('Version') ] + assert Mailer.deliver_attachments_added(attachements) + assert_not_nil last_email.bcc + assert last_email.bcc.any? + end + + def test_project_file_added + attachements = [ Attachment.find_by_container_type('Project') ] + assert Mailer.deliver_attachments_added(attachements) + assert_not_nil last_email.bcc + assert last_email.bcc.any? + end + def test_news_added news = News.find(:first) valid_languages.each do |lang|