FIX: Ensure ends_at is set correctly on resolved alerts

FIX: Ensure ends_at is set correctly on resolved alerts

diff --git a/app/jobs/concerns/alert_post_mixin.rb b/app/jobs/concerns/alert_post_mixin.rb
index 0c3347f..54c6770 100644
--- a/app/jobs/concerns/alert_post_mixin.rb
+++ b/app/jobs/concerns/alert_post_mixin.rb
@@ -34,7 +34,7 @@ module AlertPostMixin
         alert[:grafana_url] = "#{grafana_url}#{dashboard_path}"
       end
 
-      alert[:ends_at] = nil if alert['status'] != 'resolved'
+      alert[:ends_at] = nil if alert[:status] != 'resolved'
 
       alert
     end
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 2f23431..601dfe6 100644
--- a/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb
+++ b/spec/integration/discourse_prometheus_alert_receiver/receiver_controller_spec.rb
@@ -928,6 +928,10 @@ RSpec.describe DiscoursePrometheusAlertReceiver::ReceiverController do
             expect(topic.tags.pluck(:name)).to contain_exactly(
               datacenter, AlertPostMixin::HIGH_PRIORITY_TAG
             )
+
+            alert = topic.alert_receiver_alerts.first
+            expect(alert.status).to eq('resolved')
+            expect(alert.ends_at).to eq_time(DateTime.parse('2020-01-02T09:08:07.09876543Z'))
           end
         end
 

GitHub sha: 589329e8