aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rw-r--r--lib/mauve/notification.rb11
-rw-r--r--test/tc_mauve_notification.rb22
3 files changed, 35 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 39dfebb..aeb3194 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
mauvealert (3.8.1) stable; urgency=low
* Calendar now honours http timeout + ssl verify settings.
+ * Added no_one_in test for DuringRunner
- -- Patrick J Cherry <patrick@bytemark.co.uk> Fri, 27 Apr 2012 09:11:17 +0100
+ -- Patrick J Cherry <patrick@bytemark.co.uk> Fri, 27 Apr 2012 09:32:02 +0100
mauvealert (3.8.0) stable; urgency=low
diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb
index 5877e0f..8a5d241 100644
--- a/lib/mauve/notification.rb
+++ b/lib/mauve/notification.rb
@@ -115,6 +115,17 @@ module Mauve
protected
+ # Test to see if a people_list is empty.
+ #
+ # @param [String] people_list People list to query
+ # @return [Boolean]
+ #
+ def no_one_in(people_list)
+ return true unless Configuration.current.people_lists.has_key?(people_list)
+
+ return Configuration.current.people_lists[people_list].people.empty?
+ end
+
# Returns true if the current hour is in the list of hours given.
#
# @param [Array] hours List of hours (as Integers)
diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb
index d0c2bab..7a71c47 100644
--- a/test/tc_mauve_notification.rb
+++ b/test/tc_mauve_notification.rb
@@ -165,6 +165,28 @@ class TcMauveDuringRunner < Mauve::UnitTest
assert(dr.send(:unacknowledged, 1.hour))
end
+ def test_no_one_in
+ config=<<EOF
+person "test1"
+person "test2"
+
+people_list "empty", %w( )
+people_list "not empty", %w(test1 test2)
+EOF
+
+ Configuration.current = ConfigurationBuilder.parse(config)
+
+ dr = DuringRunner.new(Time.now)
+
+ assert(dr.send(:no_one_in, "non-existent list"))
+ assert(dr.send(:no_one_in, "empty"))
+ #
+ # We expect an empty list to generate a warning.
+ #
+ logger_pop
+ assert(!dr.send(:no_one_in, "not empty"))
+ end
+
end
class TcMauveNotification < Mauve::UnitTest