Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/presenters/projects/prometheus/alert_presenter_spec.rb')
-rw-r--r--spec/presenters/projects/prometheus/alert_presenter_spec.rb35
1 files changed, 21 insertions, 14 deletions
diff --git a/spec/presenters/projects/prometheus/alert_presenter_spec.rb b/spec/presenters/projects/prometheus/alert_presenter_spec.rb
index 967a0fb2c09..8ee5a4d7b3f 100644
--- a/spec/presenters/projects/prometheus/alert_presenter_spec.rb
+++ b/spec/presenters/projects/prometheus/alert_presenter_spec.rb
@@ -24,18 +24,25 @@ describe Projects::Prometheus::AlertPresenter do
it { is_expected.to eq(project.full_path) }
end
- describe '#starts_at' do
- subject { presenter.starts_at }
+ describe '#start_time' do
+ subject { presenter.start_time }
+
+ let(:starts_at) { '2020-10-31T14:02:04Z' }
before do
payload['startsAt'] = starts_at
end
- context 'with valid datetime' do
- let(:datetime) { Time.now }
- let(:starts_at) { datetime.rfc3339 }
+ context 'with valid utc datetime' do
+ it { is_expected.to eq('31 October 2020, 2:02PM (UTC)') }
- it { is_expected.to eq(datetime.rfc3339) }
+ context 'with admin time zone not UTC' do
+ before do
+ allow(Time).to receive(:zone).and_return(ActiveSupport::TimeZone.new('Perth'))
+ end
+
+ it { is_expected.to eq('31 October 2020, 2:02PM (UTC)') }
+ end
end
context 'with invalid datetime' do
@@ -56,7 +63,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}
+ **Start time:** #{presenter.start_time}
MARKDOWN
)
@@ -73,7 +80,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}
+ **Start time:** #{presenter.start_time}
#### Alert Details
@@ -94,7 +101,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}#{markdown_line_break}
+ **Start time:** #{presenter.start_time}#{markdown_line_break}
**full_query:** `query`
MARKDOWN
@@ -122,7 +129,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}#{markdown_line_break}
+ **Start time:** #{presenter.start_time}#{markdown_line_break}
**Service:** service_name#{markdown_line_break}
**Monitoring tool:** monitoring_tool_name#{markdown_line_break}
**Hosts:** http://localhost:3000 http://localhost:3001
@@ -144,7 +151,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}#{markdown_line_break}
+ **Start time:** #{presenter.start_time}#{markdown_line_break}
**Hosts:** http://localhost:3000
MARKDOWN
@@ -161,7 +168,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}#{markdown_line_break}
+ **Start time:** #{presenter.start_time}#{markdown_line_break}
**full_query:** `avg(metric) > 1.0`
[](#{url})
@@ -253,7 +260,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}#{markdown_line_break}
+ **Start time:** #{presenter.start_time}#{markdown_line_break}
**full_query:** `avg(metric) > 1.0`
MARKDOWN
@@ -280,7 +287,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
- **Start time:** #{presenter.starts_at}
+ **Start time:** #{presenter.start_time}
MARKDOWN
end