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/models/environment_spec.rb')
-rw-r--r--spec/models/environment_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index c449a3c3c47..2696d144db4 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -19,6 +19,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
it { is_expected.to have_many(:deployments) }
it { is_expected.to have_many(:metrics_dashboard_annotations) }
it { is_expected.to have_many(:alert_management_alerts) }
+ it { is_expected.to have_one(:latest_opened_most_severe_alert) }
it { is_expected.to delegate_method(:stop_action).to(:last_deployment) }
it { is_expected.to delegate_method(:manual_actions).to(:last_deployment) }
@@ -1347,4 +1348,27 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
expect(project.environments.count_by_state).to eq({ stopped: 0, available: 0 })
end
end
+
+ describe '#has_opened_alert?' do
+ subject { environment.has_opened_alert? }
+
+ let_it_be(:project) { create(:project) }
+ let_it_be(:environment, reload: true) { create(:environment, project: project) }
+
+ context 'when environment has an triggered alert' do
+ let!(:alert) { create(:alert_management_alert, :triggered, project: project, environment: environment) }
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when environment has an resolved alert' do
+ let!(:alert) { create(:alert_management_alert, :resolved, project: project, environment: environment) }
+
+ it { is_expected.to be(false) }
+ end
+
+ context 'when environment does not have an alert' do
+ it { is_expected.to be(false) }
+ end
+ end
end