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')
-rw-r--r--spec/models/ci/build_spec.rb21
-rw-r--r--spec/models/commit_status_spec.rb66
2 files changed, 87 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 8a701a461c0..900e0feaccc 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -815,6 +815,27 @@ describe Ci::Build do
it { is_expected.to contain_exactly(build, rspec_test, rubocop_test, staging) }
end
end
+
+ describe '#all_dependencies' do
+ let!(:final_build) do
+ create(:ci_build,
+ pipeline: pipeline, name: 'deploy',
+ stage_idx: 3, stage: 'deploy'
+ )
+ end
+
+ subject { final_build.all_dependencies }
+
+ it 'returns dependencies and cross_dependencies' do
+ dependencies = [1, 2, 3]
+ cross_dependencies = [3, 4]
+
+ allow(final_build).to receive(:dependencies).and_return(dependencies)
+ allow(final_build).to receive(:cross_dependencies).and_return(cross_dependencies)
+
+ is_expected.to match(a_collection_containing_exactly(1, 2, 3, 4))
+ end
+ end
end
describe '#triggered_by?' do
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 1e1b679a32c..31aebac54e1 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -312,6 +312,72 @@ describe CommitStatus do
end
end
+ describe '.for_ref' do
+ subject { described_class.for_ref('bb').order(:id) }
+
+ let(:statuses) do
+ [create_status(ref: 'aa'),
+ create_status(ref: 'bb'),
+ create_status(ref: 'cc')]
+ end
+
+ it 'returns statuses with the specified ref' do
+ is_expected.to eq(statuses.values_at(1))
+ end
+ end
+
+ describe '.by_name' do
+ subject { described_class.by_name('bb').order(:id) }
+
+ let(:statuses) do
+ [create_status(name: 'aa'),
+ create_status(name: 'bb'),
+ create_status(name: 'cc')]
+ end
+
+ it 'returns statuses with the specified name' do
+ is_expected.to eq(statuses.values_at(1))
+ end
+ end
+
+ describe '.for_project_paths' do
+ subject do
+ described_class
+ .for_project_paths(paths)
+ .order(:id)
+ end
+
+ context 'with a single path' do
+ let(:other_project) { create(:project, :repository) }
+ let(:paths) { other_project.full_path }
+
+ let(:other_pipeline) do
+ create(:ci_pipeline, project: other_project, sha: other_project.commit.id)
+ end
+
+ let(:statuses) do
+ [create_status(pipeline: pipeline),
+ create_status(pipeline: other_pipeline)]
+ end
+
+ it 'returns statuses for other_project' do
+ is_expected.to eq(statuses.values_at(1))
+ end
+ end
+
+ context 'with array of paths' do
+ let(:paths) { [project.full_path] }
+
+ let(:statuses) do
+ [create_status(pipeline: pipeline)]
+ end
+
+ it 'returns statuses for project' do
+ is_expected.to eq(statuses.values_at(0))
+ end
+ end
+ end
+
describe '.status' do
context 'when there are multiple statuses present' do
before do