summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/watchers_controller_test.rb21
-rw-r--r--test/unit/mailer_test.rb11
2 files changed, 32 insertions, 0 deletions
diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb
index 1faf4b06e..8ec2aa112 100644
--- a/test/functional/watchers_controller_test.rb
+++ b/test/functional/watchers_controller_test.rb
@@ -56,6 +56,27 @@ class WatchersControllerTest < ActionController::TestCase
assert Issue.find(3).watched_by?(User.find(3))
end
+ def test_watch_a_news_module_should_add_watcher
+ @request.session[:user_id] = 7
+ assert_not_nil m = Project.find(1).enabled_module('news')
+
+ assert_difference 'Watcher.count' do
+ xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s
+ assert_response :success
+ end
+ assert m.reload.watched_by?(User.find(7))
+ end
+
+ def test_watch_a_private_news_module_without_permission_should_fail
+ @request.session[:user_id] = 7
+ assert_not_nil m = Project.find(2).enabled_module('news')
+
+ assert_no_difference 'Watcher.count' do
+ xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s
+ assert_response 403
+ end
+ end
+
def test_watch_should_be_denied_without_permission
Role.find(2).remove_permission! :view_issues
@request.session[:user_id] = 3
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index b5f4086f7..5c155e6a5 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -467,6 +467,17 @@ class MailerTest < ActiveSupport::TestCase
end
end
+ def test_news_added_should_notify_project_news_watchers
+ user1 = User.generate!
+ user2 = User.generate!
+ news = News.first
+ news.project.enabled_module('news').add_watcher(user1)
+
+ Mailer.news_added(news).deliver
+ assert_include user1.mail, last_email.bcc
+ assert_not_include user2.mail, last_email.bcc
+ end
+
def test_news_comment_added
comment = Comment.find(2)
valid_languages.each do |lang|