Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix upcoming change logging for NotifyPromotion (#41967)

Martin Brennan6fd9ae05e649
diff --git a/app/jobs/scheduled/check_upcoming_changes.rb b/app/jobs/scheduled/check_upcoming_changes.rb
index f6a353e7276..7aff9598f7d 100644
--- a/app/jobs/scheduled/check_upcoming_changes.rb
+++ b/app/jobs/scheduled/check_upcoming_changes.rb
@@ -85,7 +85,12 @@ module Jobs
:error
end
- backtrace = (status[:backtrace] || status[:result_inspect_steps])&.join("\n") || "N/A"
+ backtrace =
+ if status[:backtrace].present?
+ backtrace = status[:backtrace]&.join("\n")
+ else
+ backtrace = status[:result_inspect_steps] || "N/A"
+ end
verbose_log(
site,
diff --git a/app/services/upcoming_changes/notify_promotions.rb b/app/services/upcoming_changes/notify_promotions.rb
index 9322b25fecc..71b072398c7 100644
--- a/app/services/upcoming_changes/notify_promotions.rb
+++ b/app/services/upcoming_changes/notify_promotions.rb
@@ -46,6 +46,11 @@ class UpcomingChanges::NotifyPromotions
status_hash[:error_key] = :setting_not_available
end
+ on_failed_policy(:should_notify_admins) do |policy|
+ status_hash[:error] = "Setting #{setting_name} should not notify admins about promotion"
+ status_hash[:error_key] = :should_not_notify_admins
+ end
+
on_failed_policy(:change_should_be_displayed) do |policy|
status_hash[
:error
@@ -81,14 +86,6 @@ class UpcomingChanges::NotifyPromotions
end
end
- if !status_hash[:success] && (!status_hash[:error_key] || !status_hash[:error])
- status_hash[
- :error
- ] = "An unexpected error in UpcomingChanges::NotifyPromotion occurred while notifying about promotion of #{setting_name}"
- status_hash[:error_key] = :unexpected_error
- status_hash[:result_inspect_steps] = result.inspect_steps
- end
-
status_hash
end
end