##// END OF EJS Templates
Don't use #delete on String in Mailer....
Jean-Philippe Lang -
r9117:95b10f3bd388
parent child
Show More
@@ -98,6 +98,7 class Mailer < ActionMailer::Base
98 98 def document_added(document)
99 99 redmine_headers 'Project' => document.project.identifier
100 100 recipients document.recipients
101 @author = User.current
101 102 subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
102 103 body :document => document,
103 104 :document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
@@ -113,6 +114,7 class Mailer < ActionMailer::Base
113 114 container = attachments.first.container
114 115 added_to = ''
115 116 added_to_url = ''
117 @author = attachments.first.author
116 118 case container.class.name
117 119 when 'Project'
118 120 added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
@@ -142,6 +144,7 class Mailer < ActionMailer::Base
142 144 # Mailer.deliver_news_added(news) => sends an email to the news' project recipients
143 145 def news_added(news)
144 146 redmine_headers 'Project' => news.project.identifier
147 @author = news.author
145 148 message_id news
146 149 recipients news.recipients
147 150 subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
@@ -158,6 +161,7 class Mailer < ActionMailer::Base
158 161 def news_comment_added(comment)
159 162 news = comment.commented
160 163 redmine_headers 'Project' => news.project.identifier
164 @author = comment.author
161 165 message_id comment
162 166 recipients news.recipients
163 167 cc news.watcher_recipients
@@ -176,6 +180,7 class Mailer < ActionMailer::Base
176 180 def message_posted(message)
177 181 redmine_headers 'Project' => message.project.identifier,
178 182 'Topic-Id' => (message.parent_id || message.id)
183 @author = message.author
179 184 message_id message
180 185 references message.parent unless message.parent.nil?
181 186 recipients(message.recipients)
@@ -194,6 +199,7 class Mailer < ActionMailer::Base
194 199 def wiki_content_added(wiki_content)
195 200 redmine_headers 'Project' => wiki_content.project.identifier,
196 201 'Wiki-Page-Id' => wiki_content.page.id
202 @author = wiki_content.author
197 203 message_id wiki_content
198 204 recipients wiki_content.recipients
199 205 cc(wiki_content.page.wiki.watcher_recipients - recipients)
@@ -213,6 +219,7 class Mailer < ActionMailer::Base
213 219 def wiki_content_updated(wiki_content)
214 220 redmine_headers 'Project' => wiki_content.project.identifier,
215 221 'Wiki-Page-Id' => wiki_content.page.id
222 @author = wiki_content.author
216 223 message_id wiki_content
217 224 recipients wiki_content.recipients
218 225 cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
@@ -387,15 +394,18 class Mailer < ActionMailer::Base
387 394
388 395 # Overrides the create_mail method
389 396 def create_mail
390 # Removes the current user from the recipients and cc
397 # Removes the author from the recipients and cc
391 398 # if he doesn't want to receive notifications about what he does
392 @author ||= User.current
393 if @author.pref[:no_self_notified]
394 recipients.delete(@author.mail) if recipients
395 cc.delete(@author.mail) if cc
399 if @author && @author.logged? && @author.pref[:no_self_notified]
400 if recipients
401 recipients((recipients.is_a?(Array) ? recipients : [recipients]) - [@author.mail])
402 end
403 if cc
404 cc((cc.is_a?(Array) ? cc : [cc]) - [@author.mail])
405 end
396 406 end
397 407
398 if @author.logged?
408 if @author && @author.logged?
399 409 redmine_headers 'Sender' => @author.login
400 410 end
401 411
@@ -84,6 +84,11 class AdminControllerTest < ActionController::TestCase
84 84 end
85 85
86 86 def test_test_email
87 user = User.find(1)
88 user.pref[:no_self_notified] = '1'
89 user.pref.save!
90 ActionMailer::Base.deliveries.clear
91
87 92 get :test_email
88 93 assert_redirected_to '/settings/edit?tab=notifications'
89 94 mail = ActionMailer::Base.deliveries.last
General Comments 0
You need to be logged in to leave comments. Login now