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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-23 21:09:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-23 21:09:28 +0300
commit901af2a0dd967f1a87195aed8e92ee05e9561c1d (patch)
treea187e22282338c3eaa391a3bf84da38b636ce7ab /spec/models
parent5eeb39104356356bec81abe19479bca591e6f299 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/alert_management/alert_spec.rb18
-rw-r--r--spec/models/ci/pipeline_spec.rb23
-rw-r--r--spec/models/integration_spec.rb11
3 files changed, 46 insertions, 6 deletions
diff --git a/spec/models/alert_management/alert_spec.rb b/spec/models/alert_management/alert_spec.rb
index 27b8bb48073..4e956d9fc18 100644
--- a/spec/models/alert_management/alert_spec.rb
+++ b/spec/models/alert_management/alert_spec.rb
@@ -337,4 +337,22 @@ describe AlertManagement::Alert do
expect { subject }.to change { alert.events }.by(1)
end
end
+
+ describe '#present' do
+ context 'when alert is generic' do
+ let(:alert) { build(:alert_management_alert) }
+
+ it 'uses generic alert presenter' do
+ expect(alert.present).to be_kind_of(AlertManagement::AlertPresenter)
+ end
+ end
+
+ context 'when alert is Prometheus specific' do
+ let(:alert) { build(:alert_management_alert, :prometheus) }
+
+ it 'uses Prometheus Alert presenter' do
+ expect(alert.present).to be_kind_of(AlertManagement::PrometheusAlertPresenter)
+ end
+ end
+ end
end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index dfcb9c1ff43..5e4eab3bf3a 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -1488,6 +1488,12 @@ describe Ci::Pipeline, :mailer do
sha: project.commit.sha)
end
+ describe '#lazy_ref_commit' do
+ it 'returns the latest commit for a ref lazily' do
+ expect(pipeline.lazy_ref_commit.id).to eq project.commit(pipeline.ref).id
+ end
+ end
+
describe '#latest?' do
context 'with latest sha' do
it 'returns true' do
@@ -1496,17 +1502,26 @@ describe Ci::Pipeline, :mailer do
end
context 'with a branch name as the ref' do
- it 'looks up commit with the full ref name' do
- expect(pipeline.project).to receive(:commit).with('refs/heads/master').and_call_original
+ it 'looks up a commit for a branch' do
+ expect(pipeline.ref).to eq 'master'
+ expect(pipeline).to be_latest
+ end
+ end
+
+ context 'with a tag name as a ref' do
+ it 'looks up a commit for a tag' do
+ expect(project.repository.branch_names).not_to include 'v1.0.0'
+
+ pipeline.update(sha: project.commit('v1.0.0').sha, ref: 'v1.0.0', tag: true)
+ expect(pipeline).to be_tag
expect(pipeline).to be_latest
end
end
context 'with not latest sha' do
before do
- pipeline.update(
- sha: project.commit("#{project.default_branch}~1").sha)
+ pipeline.update(sha: project.commit("#{project.default_branch}~1").sha)
end
it 'returns false' do
diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb
index 3042fd15a7b..87ba0f3f7e6 100644
--- a/spec/models/integration_spec.rb
+++ b/spec/models/integration_spec.rb
@@ -3,8 +3,9 @@
require 'spec_helper'
RSpec.describe Integration do
- let(:project_1) { create(:project) }
- let(:project_2) { create(:project) }
+ let!(:project_1) { create(:project) }
+ let!(:project_2) { create(:project) }
+ let!(:project_3) { create(:project) }
let(:instance_integration) { create(:jira_service, :instance) }
before do
@@ -18,4 +19,10 @@ RSpec.describe Integration do
expect(Project.with_custom_integration_for(instance_integration)).to contain_exactly(project_2)
end
end
+
+ describe '#ids_without_integration' do
+ it 'returns projects ids without an integration' do
+ expect(Project.ids_without_integration(instance_integration, 100)).to contain_exactly(project_3.id)
+ end
+ end
end