aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-11-26 17:04:38 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-11-26 17:04:38 +0000
commitfc848abc8f5cb9452c7b929f6f1212d305b5cbdb (patch)
tree19f305243f7549ab5c3e8ff9a40db3f7ebab9ffc
parent8887d2bf22971405c300b7cf3ad8d7f4d6269b0e (diff)
Updated alert changed to log when saves fail, but saves them anyway.
-rw-r--r--lib/mauve/alert_changed.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/mauve/alert_changed.rb b/lib/mauve/alert_changed.rb
index 1712c7e..b76df58 100644
--- a/lib/mauve/alert_changed.rb
+++ b/lib/mauve/alert_changed.rb
@@ -108,13 +108,22 @@ module Mauve
#
self.remind_at = nil
- if self.save
- logger.debug "Successfully cleared #{self}"
- true
- else
- logger.warn "Failed to clear #{self} -- this will lead to duplicate reminders."
- false
+ unless self.save
+ #
+ # If the save has failed due to validation errors, but there aren't
+ # actually any errors, just save, by-passing validation.
+ #
+ if self.respond_to?("errors") and self.errors.is_a?(DataMapper::Validations::ValidationErrors) and self.errors.errors.empty?
+ logger.debug "Failed to save #{self.inspect} due to unexplained validation error. Saving again skipping validation."
+ self.save!
+ return true
+ else
+ logger.warn "Failed to clear #{self.inspect}, due to #{self.errors.inspect} -- this will lead to duplicate reminders."
+ return false
+ end
end
+
+ return true
end
# The time this AlertChanged should next be polled at, or nil. Mimics