Adds email notifications support for news comments (#2074).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5003 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-03-04 14:32:58 +00:00
parent 8d3773e0e1
commit 36009de154
14 changed files with 100 additions and 15 deletions
+11 -2
View File
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -31,6 +31,15 @@ class CommentTest < ActiveSupport::TestCase
@news.reload
assert_equal 2, @news.comments_count
end
def test_create_should_send_notification
Setting.notified_events << 'news_comment_added'
Watcher.create!(:watchable => @news, :user => @jsmith)
assert_difference 'ActionMailer::Base.deliveries.size' do
Comment.create!(:commented => @news, :author => @jsmith, :comments => "my comment")
end
end
def test_validate
comment = Comment.new(:commented => @news)
+4 -4
View File
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006-2008 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -22,9 +22,9 @@ class Redmine::NotifiableTest < ActiveSupport::TestCase
end
def test_all
assert_equal 11, Redmine::Notifiable.all.length
assert_equal 12, Redmine::Notifiable.all.length
%w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
%w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added news_comment_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
end
end
+11 -3
View File
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -20,7 +20,7 @@ require File.expand_path('../../test_helper', __FILE__)
class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
include ActionController::Assertions::SelectorAssertions
fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
fixtures :all
def setup
ActionMailer::Base.deliveries.clear
@@ -295,6 +295,14 @@ class MailerTest < ActiveSupport::TestCase
end
end
def test_news_comment_added
comment = Comment.find(2)
valid_languages.each do |lang|
Setting.default_language = lang.to_s
assert Mailer.deliver_news_comment_added(comment)
end
end
def test_message_posted
message = Message.find(:first)
recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}