Don't use #delete on String in Mailer.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9237 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
dd1b2876b1
commit
95b10f3bd3
|
@ -98,6 +98,7 @@ class Mailer < ActionMailer::Base
|
||||||
def document_added(document)
|
def document_added(document)
|
||||||
redmine_headers 'Project' => document.project.identifier
|
redmine_headers 'Project' => document.project.identifier
|
||||||
recipients document.recipients
|
recipients document.recipients
|
||||||
|
@author = User.current
|
||||||
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
||||||
body :document => document,
|
body :document => document,
|
||||||
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
|
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
|
||||||
|
@ -113,6 +114,7 @@ class Mailer < ActionMailer::Base
|
||||||
container = attachments.first.container
|
container = attachments.first.container
|
||||||
added_to = ''
|
added_to = ''
|
||||||
added_to_url = ''
|
added_to_url = ''
|
||||||
|
@author = attachments.first.author
|
||||||
case container.class.name
|
case container.class.name
|
||||||
when 'Project'
|
when 'Project'
|
||||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||||
|
@ -142,6 +144,7 @@ class Mailer < ActionMailer::Base
|
||||||
# Mailer.deliver_news_added(news) => sends an email to the news' project recipients
|
# Mailer.deliver_news_added(news) => sends an email to the news' project recipients
|
||||||
def news_added(news)
|
def news_added(news)
|
||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
|
@author = news.author
|
||||||
message_id news
|
message_id news
|
||||||
recipients news.recipients
|
recipients news.recipients
|
||||||
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
||||||
|
@ -158,6 +161,7 @@ class Mailer < ActionMailer::Base
|
||||||
def news_comment_added(comment)
|
def news_comment_added(comment)
|
||||||
news = comment.commented
|
news = comment.commented
|
||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
|
@author = comment.author
|
||||||
message_id comment
|
message_id comment
|
||||||
recipients news.recipients
|
recipients news.recipients
|
||||||
cc news.watcher_recipients
|
cc news.watcher_recipients
|
||||||
|
@ -176,6 +180,7 @@ class Mailer < ActionMailer::Base
|
||||||
def message_posted(message)
|
def message_posted(message)
|
||||||
redmine_headers 'Project' => message.project.identifier,
|
redmine_headers 'Project' => message.project.identifier,
|
||||||
'Topic-Id' => (message.parent_id || message.id)
|
'Topic-Id' => (message.parent_id || message.id)
|
||||||
|
@author = message.author
|
||||||
message_id message
|
message_id message
|
||||||
references message.parent unless message.parent.nil?
|
references message.parent unless message.parent.nil?
|
||||||
recipients(message.recipients)
|
recipients(message.recipients)
|
||||||
|
@ -194,6 +199,7 @@ class Mailer < ActionMailer::Base
|
||||||
def wiki_content_added(wiki_content)
|
def wiki_content_added(wiki_content)
|
||||||
redmine_headers 'Project' => wiki_content.project.identifier,
|
redmine_headers 'Project' => wiki_content.project.identifier,
|
||||||
'Wiki-Page-Id' => wiki_content.page.id
|
'Wiki-Page-Id' => wiki_content.page.id
|
||||||
|
@author = wiki_content.author
|
||||||
message_id wiki_content
|
message_id wiki_content
|
||||||
recipients wiki_content.recipients
|
recipients wiki_content.recipients
|
||||||
cc(wiki_content.page.wiki.watcher_recipients - recipients)
|
cc(wiki_content.page.wiki.watcher_recipients - recipients)
|
||||||
|
@ -213,6 +219,7 @@ class Mailer < ActionMailer::Base
|
||||||
def wiki_content_updated(wiki_content)
|
def wiki_content_updated(wiki_content)
|
||||||
redmine_headers 'Project' => wiki_content.project.identifier,
|
redmine_headers 'Project' => wiki_content.project.identifier,
|
||||||
'Wiki-Page-Id' => wiki_content.page.id
|
'Wiki-Page-Id' => wiki_content.page.id
|
||||||
|
@author = wiki_content.author
|
||||||
message_id wiki_content
|
message_id wiki_content
|
||||||
recipients wiki_content.recipients
|
recipients wiki_content.recipients
|
||||||
cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
|
cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
|
||||||
|
@ -387,15 +394,18 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Overrides the create_mail method
|
# Overrides the create_mail method
|
||||||
def create_mail
|
def create_mail
|
||||||
# Removes the current user from the recipients and cc
|
# Removes the author from the recipients and cc
|
||||||
# if he doesn't want to receive notifications about what he does
|
# if he doesn't want to receive notifications about what he does
|
||||||
@author ||= User.current
|
if @author && @author.logged? && @author.pref[:no_self_notified]
|
||||||
if @author.pref[:no_self_notified]
|
if recipients
|
||||||
recipients.delete(@author.mail) if recipients
|
recipients((recipients.is_a?(Array) ? recipients : [recipients]) - [@author.mail])
|
||||||
cc.delete(@author.mail) if cc
|
end
|
||||||
|
if cc
|
||||||
|
cc((cc.is_a?(Array) ? cc : [cc]) - [@author.mail])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @author.logged?
|
if @author && @author.logged?
|
||||||
redmine_headers 'Sender' => @author.login
|
redmine_headers 'Sender' => @author.login
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,11 @@ class AdminControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_test_email
|
def test_test_email
|
||||||
|
user = User.find(1)
|
||||||
|
user.pref[:no_self_notified] = '1'
|
||||||
|
user.pref.save!
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
get :test_email
|
get :test_email
|
||||||
assert_redirected_to '/settings/edit?tab=notifications'
|
assert_redirected_to '/settings/edit?tab=notifications'
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
|
|
Loading…
Reference in New Issue