Extract EE specific files/lines for spec/models/ci
We have the following files containing EE specific code. We should move them to ee/
spec/models/ci/build_spec.rb
diff --git a/spec/models/ci/build_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/build_spec.rb
index 81ff727b458..3e46ddf0589 100644
--- a/spec/models/ci/build_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/build_spec.rb
@@ -17,6 +17,7 @@ describe Ci::Build do
it { is_expected.to belong_to(:runner) }
it { is_expected.to belong_to(:trigger_request) }
it { is_expected.to belong_to(:erased_by) }
+ it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_many(:trace_sections)}
it { is_expected.to have_one(:deployment) }
it { is_expected.to have_one(:runner_session)}
spec/models/ci/pipeline_spec.rb
diff --git a/spec/models/ci/pipeline_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/pipeline_spec.rb
index b9567ab4d65..e2688ce0ac9 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/pipeline_spec.rb
@@ -22,6 +22,10 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:auto_canceled_pipelines) }
it { is_expected.to have_many(:auto_canceled_jobs) }
+ it { is_expected.to have_one(:source_pipeline) }
+ it { is_expected.to have_many(:sourced_pipelines) }
+ it { is_expected.to have_one(:triggered_by_pipeline) }
+ it { is_expected.to have_many(:triggered_pipelines) }
it { is_expected.to have_one(:chat_data) }
it { is_expected.to validate_presence_of(:sha) }
@@ -481,7 +485,8 @@ describe Ci::Pipeline, :mailer do
describe 'pipeline stages' do
describe '#stage_seeds' do
- let(:pipeline) { build(:ci_pipeline, config: config) }
+ let(:project) { create(:project, :repository) }
+ let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
let(:config) { { rspec: { script: 'rake' } } }
it 'returns preseeded stage seeds object' do
@@ -511,7 +516,7 @@ describe Ci::Pipeline, :mailer do
context 'when refs policy is specified' do
let(:pipeline) do
- build(:ci_pipeline, ref: 'feature', tag: true, config: config)
+ build(:ci_pipeline, ref: 'feature', tag: true, project: project, config: config)
end
let(:config) do
@@ -529,7 +534,9 @@ describe Ci::Pipeline, :mailer do
end
context 'when source policy is specified' do
- let(:pipeline) { build(:ci_pipeline, source: :schedule, config: config) }
+ let(:pipeline) do
+ build(:ci_pipeline, source: :schedule, project: project, config: config)
+ end
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['triggers'] },
@@ -569,7 +576,7 @@ describe Ci::Pipeline, :mailer do
end
context 'when user configured kubernetes from Integration > Kubernetes' do
- let(:project) { create(:kubernetes_project) }
+ let(:project) { create(:kubernetes_project, :repository) }
let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
@@ -611,13 +618,15 @@ describe Ci::Pipeline, :mailer do
describe '#seeds_size' do
context 'when refs policy is specified' do
+ let(:project) { create(:project, :repository) }
+
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['master'] },
spinach: { stage: 'test', script: 'spinach', only: ['tags'] } }
end
let(:pipeline) do
- build(:ci_pipeline, ref: 'feature', tag: true, config: config)
+ build(:ci_pipeline, ref: 'feature', tag: true, project: project, config: config)
end
it 'returns real seeds size' do
@@ -1547,6 +1556,23 @@ describe Ci::Pipeline, :mailer do
end
end
+ context 'the source is the repository' do
+ let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
+
+ before do
+ pipeline.repository_source!
+ end
+
+ it 'returns the configuration if found' do
+ allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
+ .and_return('config')
+
+ expect(pipeline.ci_yaml_file).to be_a(String)
+ expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
+ expect(pipeline.yaml_errors).to be_nil
+ end
+ end
+
context 'when pipeline is for auto-devops' do
before do
pipeline.config_source = 'auto_devops_source'
@@ -2212,8 +2238,9 @@ describe Ci::Pipeline, :mailer do
end
context 'when pipeline does not have errors' do
+ let(:project) { create(:project, :repository) }
let(:pipeline) do
- create(:ci_pipeline, config: { rspec: { script: 'rake test' } })
+ create(:ci_pipeline, project: project, config: { rspec: { script: 'rake test' } })
end
it 'does not contain yaml errors' do
spec/models/ci/variable_spec.rb
diff --git a/spec/models/ci/variable_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/variable_spec.rb
index 02c07a2bd83..e9e55fe9f6e 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/ci/variable_spec.rb
@@ -4,6 +4,12 @@ describe Ci::Variable do
subject { build(:ci_variable) }
describe 'validations' do
+ # EE
+ before do
+ stub_licensed_features(variable_environment_scope: true)
+ end
+
+ it { is_expected.to include_module(HasEnvironmentScope) }
it { is_expected.to include_module(HasVariable) }
it { is_expected.to include_module(Presentable) }
it { is_expected.to include_module(Maskable) }
Edited by Yorick Peterse