diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 03:08:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 03:08:35 +0300 |
commit | 16210ba9db55eeb1cd4c83c8a679ad4e97dd3d48 (patch) | |
tree | efd0bd7c3fdf6f3ebb291d2e3aef86dca453b950 /spec/models | |
parent | 1b16af5ff9da84ff7779ea7d7db977d7c056baca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 44 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 24 |
2 files changed, 68 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 6fdd8463329..4caf80eaf7d 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1811,6 +1811,50 @@ describe Ci::Build do end end + describe '.keep_artifacts!' do + let!(:build) { create(:ci_build, artifacts_expire_at: Time.current + 7.days) } + let!(:builds_for_update) do + Ci::Build.where(id: create_list(:ci_build, 3, artifacts_expire_at: Time.current + 7.days).map(&:id)) + end + + it 'resets expire_at' do + builds_for_update.keep_artifacts! + + builds_for_update.each do |build| + expect(build.reload.artifacts_expire_at).to be_nil + end + end + + it 'does not reset expire_at for other builds' do + builds_for_update.keep_artifacts! + + expect(build.reload.artifacts_expire_at).to be_present + end + + context 'when having artifacts files' do + let!(:artifact) { create(:ci_job_artifact, job: build, expire_in: '7 days') } + let!(:artifacts_for_update) do + builds_for_update.map do |build| + create(:ci_job_artifact, job: build, expire_in: '7 days') + end + end + + it 'resets dependent objects' do + builds_for_update.keep_artifacts! + + artifacts_for_update.each do |artifact| + expect(artifact.reload.expire_at).to be_nil + end + end + + it 'does not reset dependent object for other builds' do + builds_for_update.keep_artifacts! + + expect(artifact.reload.expire_at).to be_present + end + end + end + describe '#keep_artifacts!' do let(:build) { create(:ci_build, artifacts_expire_at: Time.current + 7.days) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 9ec306d297e..d39cde016a5 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -5886,6 +5886,30 @@ describe Project do end end + describe '#prometheus_service_active?' do + let(:project) { create(:project) } + + subject { project.prometheus_service_active? } + + before do + create(:prometheus_service, project: project, manual_configuration: manual_configuration) + end + + context 'when project has an activated prometheus service' do + let(:manual_configuration) { true } + + it { is_expected.to be_truthy } + end + + context 'when project has an inactive prometheus service' do + let(:manual_configuration) { false } + + it 'the service is marked as inactive' do + expect(subject).to be_falsey + end + end + end + describe '#self_monitoring?' do let_it_be(:project) { create(:project) } |