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>2019-12-12 09:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 09:07:42 +0300
commit8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461 (patch)
tree1ffd5ffed59b0f752fc358524f4d2170f6694cb9 /spec/models/ci/build_spec.rb
parent2ccde70b80730fd52f75797e7d711748fb5b769b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r--spec/models/ci/build_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index acc54338a10..bcab621ab6a 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1275,6 +1275,68 @@ describe Ci::Build do
end
end
+ describe '#requires_resource?' do
+ subject { build.requires_resource? }
+
+ context 'when build needs a resource from a resource group' do
+ let(:resource_group) { create(:ci_resource_group, project: project) }
+ let(:build) { create(:ci_build, resource_group: resource_group, project: project) }
+
+ context 'when build has not retained a resource' do
+ it { is_expected.to eq(true) }
+ end
+
+ context 'when build has retained a resource' do
+ before do
+ resource_group.retain_resource_for(build)
+ end
+
+ it { is_expected.to eq(false) }
+
+ context 'when ci_resource_group feature flag is disabled' do
+ before do
+ stub_feature_flags(ci_resource_group: false)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
+ end
+
+ context 'when build does not need a resource from a resource group' do
+ let(:build) { create(:ci_build, project: project) }
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ describe '#retains_resource?' do
+ subject { build.retains_resource? }
+
+ context 'when build needs a resource from a resource group' do
+ let(:resource_group) { create(:ci_resource_group, project: project) }
+ let(:build) { create(:ci_build, resource_group: resource_group, project: project) }
+
+ context 'when build has retained a resource' do
+ before do
+ resource_group.retain_resource_for(build)
+ end
+
+ it { is_expected.to eq(true) }
+ end
+
+ context 'when build has not retained a resource' do
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ context 'when build does not need a resource from a resource group' do
+ let(:build) { create(:ci_build, project: project) }
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
describe '#stops_environment?' do
subject { build.stops_environment? }