Commit ac4de842 authored by James Fargher's avatar James Fargher

Merge branch 'sarnold-fix-alert-slack-time-format' into 'master'

Add space to fix time format

See merge request gitlab-org/gitlab!34475
parents 6fc2987d 28a3062a
...@@ -68,7 +68,7 @@ module ChatMessage ...@@ -68,7 +68,7 @@ module ChatMessage
# April 23rd, 2020 1:06AM UTC # April 23rd, 2020 1:06AM UTC
def format_time(time) def format_time(time)
time = Time.zone.parse(time.to_s) time = Time.zone.parse(time.to_s)
time.strftime("%B #{time.day.ordinalize}, %Y%l:%M%p %Z") time.strftime("%B #{time.day.ordinalize}, %Y %l:%M%p %Z")
end end
end end
end end
...@@ -5,7 +5,8 @@ require 'spec_helper' ...@@ -5,7 +5,8 @@ require 'spec_helper'
describe ChatMessage::AlertMessage do describe ChatMessage::AlertMessage do
subject { described_class.new(args) } subject { described_class.new(args) }
let(:alert) { create(:alert_management_alert) } let_it_be(:start_time) { Time.current }
let(:alert) { create(:alert_management_alert, started_at: start_time) }
let(:args) do let(:args) do
{ {
...@@ -44,5 +45,13 @@ describe ChatMessage::AlertMessage do ...@@ -44,5 +45,13 @@ describe ChatMessage::AlertMessage do
expect(fields).to match_array(['Severity', 'Events', 'Status', 'Start time']) expect(fields).to match_array(['Severity', 'Events', 'Status', 'Start time'])
end end
it 'returns the correctly formatted time' do
time_item = subject.attachments.first[:fields].detect { |h| h[:title] == 'Start time' }
expected_time = start_time.strftime("%B #{start_time.day.ordinalize}, %Y %l:%M%p %Z")
expect(time_item[:value]).to eq(expected_time)
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment