From 6b5646f70b1c14eadeb9778f93e078338f45f3f4 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Tue, 8 May 2012 14:21:45 +0100 Subject: Changed destroy! to destroy everywhere to ensure Histories are deleted correctly. Added test. --- test/tc_mauve_alert.rb | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/tc_mauve_alert.rb b/test/tc_mauve_alert.rb index 3af9075..269bf4c 100644 --- a/test/tc_mauve_alert.rb +++ b/test/tc_mauve_alert.rb @@ -38,10 +38,6 @@ EOF super end - def test_alert_group - - end - # # This is also the test for in_source_list? @@ -292,4 +288,31 @@ EOF end + def test_destroy_history_on_destroy + Configuration.current = ConfigurationBuilder.parse(@test_config) + Server.instance.setup + + alert = Alert.new( + :alert_id => "test_no_notification_for_old_alerts", + :source => "test", + :subject => "test" + ) + alert.save + alert.raise! + alert.reload + assert_equal(1, History.all.length) + + + Timecop.freeze(Time.now + 5.minutes) + alert.clear! + assert_equal(2, History.all.length) + + # + # OK now we destroy the alert. Destory the histories too. + # + alert.destroy + assert_equal(0, History.all.length) + + end + end -- cgit v1.2.1