diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/models/environment_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 24 |
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 |