DEV: Refactor hardcoded string into a constant.

DEV: Refactor hardcoded string into a constant.

diff --git a/app/jobs/concerns/alert_post_mixin.rb b/app/jobs/concerns/alert_post_mixin.rb
index 017754b..b034294 100644
--- a/app/jobs/concerns/alert_post_mixin.rb
+++ b/app/jobs/concerns/alert_post_mixin.rb
@@ -3,6 +3,7 @@ module AlertPostMixin
 
   FIRING_TAG = "firing".freeze
   HIGH_PRIORITY_TAG = "high-priority".freeze
+  NEXT_BUSINESS_DAY_SLA = "nbd".freeze
 
   private
 
diff --git a/app/jobs/regular/process_alert.rb b/app/jobs/regular/process_alert.rb
index 74cb354..f14b98f 100644
--- a/app/jobs/regular/process_alert.rb
+++ b/app/jobs/regular/process_alert.rb
@@ -58,7 +58,7 @@ module Jobs
           raw: raw,
           datacenters: datacenters(alert_history),
           firing: alert_history.any? { |alert| is_firing?(alert["status"]) },
-          high_priority: params["commonLabels"]["response_sla"] != next_business_day_sla
+          high_priority: params["commonLabels"]["response_sla"] != AlertPostMixin::NEXT_BUSINESS_DAY_SLA
         )
 
         assign_alert(topic, receiver) unless topic.assigned_to_user
@@ -98,7 +98,7 @@ module Jobs
 
       tags << AlertPostMixin::FIRING_TAG.dup if is_firing?(params['status'])
 
-      if params["commonLabels"]["response_sla"] != next_business_day_sla
+      if params["commonLabels"]["response_sla"] != AlertPostMixin::NEXT_BUSINESS_DAY_SLA
         tags << AlertPostMixin::HIGH_PRIORITY_TAG.dup
       end
 
@@ -156,10 +156,6 @@ module Jobs
       Group.find_by(attributes).users.sample
     end
 
-    def next_business_day_sla
-      "nbd"
-    end
-
     def assign_alert(topic, receiver, assignee: nil)
       return unless SiteSetting.prometheus_alert_receiver_enable_assign
 
diff --git a/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb b/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb
index 4768fdc..069221b 100644
--- a/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb
+++ b/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe DiscoursePrometheusAlertReceiver::ReceiverController do
     end
 
     before do
-      SiteSetting.queue_jobs = false
+      Jobs.run_immediately!
       SiteSetting.tagging_enabled = true
     end

GitHub sha: 903a09e2

1 Like