From e15138c9501a85bcafb0099b1a594035fadcc911 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 12 Sep 2011 11:17:48 +0100 Subject: Reminders are now unconditionally cleared when an alert is cleared. --- test/tc_mauve_alert_changed.rb | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'test') diff --git a/test/tc_mauve_alert_changed.rb b/test/tc_mauve_alert_changed.rb index ba31dd9..86f31d7 100644 --- a/test/tc_mauve_alert_changed.rb +++ b/test/tc_mauve_alert_changed.rb @@ -127,6 +127,64 @@ EOF end + def test_only_set_one_alert_changed_on_a_reminder_after_multiple_raises_and_clears + config=< "test", :alert_id => "test_alert", :summary => "test alert") + + # + # Raise and clear the alert multiple times. + # + 5.times do + alert.raise! + Timecop.freeze(Time.now + 15.minutes) + alert.clear! + Timecop.freeze(Time.now + 15.minutes) + end + + # + # No notification should have been sent, since it is the middle of the night + # + assert_equal(0,Server.instance.notification_buffer.length, "No notifications should have been sent.") + assert(alert.cleared?) + + # + # Raise one final time. + # + alert.raise! + # + # Still no alerts should be sent. + # + assert_equal(0,Server.instance.notification_buffer.length, "No notifications should have been sent.") + assert(alert.raised?) + + # + # Only one AlertChanged should be set now, with a reminder time of 8.30. + # + assert_equal(1, AlertChanged.all(:remind_at.not => nil).length, "Too many reminders are due to be sent.") + + end + end -- cgit v1.2.1