diff options
-rw-r--r-- | lib/mauve/alert_changed.rb | 2 | ||||
-rw-r--r-- | lib/mauve/notifiers/xmpp.rb | 2 | ||||
-rw-r--r-- | lib/mauve/web_interface.rb | 2 | ||||
-rw-r--r-- | test/tc_mauve_alert.rb | 31 |
4 files changed, 30 insertions, 7 deletions
diff --git a/lib/mauve/alert_changed.rb b/lib/mauve/alert_changed.rb index 0e0d257..2e3ac7d 100644 --- a/lib/mauve/alert_changed.rb +++ b/lib/mauve/alert_changed.rb @@ -71,7 +71,7 @@ module Mauve def remind unless alert.is_a?(Alert) logger.info "#{self.inspect} lost alert #{alert_id}. Killing self." - destroy! + destroy return false end diff --git a/lib/mauve/notifiers/xmpp.rb b/lib/mauve/notifiers/xmpp.rb index 323f89d..dc44f1c 100644 --- a/lib/mauve/notifiers/xmpp.rb +++ b/lib/mauve/notifiers/xmpp.rb @@ -677,7 +677,7 @@ EOF next end - if alert.destroy! + if alert.destroy msg << "#{alert.to_s} destroyed" else msg << "#{alert.to_s}: destruction failed." diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb index 9a46403..b5c0442 100644 --- a/lib/mauve/web_interface.rb +++ b/lib/mauve/web_interface.rb @@ -409,7 +409,7 @@ EOF post '/alert/:id/destroy' do alert = Alert.get(params[:id]) - alert.destroy! + alert.destroy flash['notice'] = "Successfully destroyed alert #{alert.alert_id} from source #{alert.source}." redirect "/" end 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 |