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>2022-03-02 03:13:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-02 03:13:45 +0300
commit90c386a7b0f2701abeb1e86517fc1d5dea231c09 (patch)
treebd31e90b87c7986276daee9020a065313db7c3ba /spec/lib/gitlab
parent70fe7ce74ba4a8430c88ec6e3f4c60475a69fe21 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb24
-rw-r--r--spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb54
2 files changed, 75 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index 885f3eaff79..97691504abd 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -420,7 +420,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
end
end
- context 'when has dependencies' do
+ context 'when it has dependencies' do
context 'that are not a array of strings' do
let(:config) do
{ script: 'echo', dependencies: 'build-job' }
@@ -433,8 +433,8 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
end
end
- context 'when has needs' do
- context 'when have dependencies that are not subset of needs' do
+ context 'when the job has needs' do
+ context 'and there are dependencies that are not included in needs' do
let(:config) do
{
stage: 'test',
@@ -448,6 +448,24 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
expect(entry).not_to be_valid
expect(entry.errors).to include 'job dependencies the another-job should be part of needs'
end
+
+ context 'and they are only cross pipeline needs' do
+ let(:config) do
+ {
+ script: 'echo',
+ dependencies: ['rspec'],
+ needs: [{
+ job: 'rspec',
+ pipeline: 'other'
+ }]
+ }
+ end
+
+ it 'adds an error for dependency keyword usage' do
+ expect(entry).not_to be_valid
+ expect(entry.errors).to include 'job needs corresponding to dependencies must be from the same pipeline'
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb b/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb
new file mode 100644
index 00000000000..cace2597633
--- /dev/null
+++ b/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Graphql::Loaders::BatchCommitLoader do
+ include RepoHelpers
+
+ describe '#find' do
+ let_it_be(:first_project) { create(:project, :repository) }
+ let_it_be(:second_project) { create(:project, :repository) }
+
+ let_it_be(:first_commit) { first_project.commit(sample_commit.id) }
+ let_it_be(:second_commit) { first_project.commit(another_sample_commit.id) }
+ let_it_be(:third_commit) { second_project.commit(sample_big_commit.id) }
+
+ it 'finds a commit by id' do
+ result = described_class.new(
+ container_class: Project,
+ container_id: first_project.id,
+ oid: first_commit.id
+ ).find
+
+ expect(result.force).to eq(first_commit)
+ end
+
+ before do
+ ActiveSupport::Notifications.subscribe('sql.active_record') do |event|
+ raise "no!" if event.payload[:sql].include?('SELECT "namespaces".')
+ end
+ end
+
+ it 'only queries once' do
+ expect do
+ [
+ described_class.new(
+ container_class: Project,
+ container_id: first_project.id,
+ oid: first_commit.id
+ ).find,
+ described_class.new(
+ container_class: Project,
+ container_id: first_project.id,
+ oid: second_commit.id
+ ).find,
+ described_class.new(
+ container_class: Project,
+ container_id: second_project.id,
+ oid: third_commit.id
+ ).find
+ ].map(&:force)
+ end.not_to exceed_query_limit(2)
+ end
+ end
+end