summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb20
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb43
-rw-r--r--spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb4
-rw-r--r--spec/lib/gitlab/import_export/project_tree_saver_spec.rb1
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb9
6 files changed, 53 insertions, 30 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index 9bccd5be4fe..75160a93ba7 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -7,9 +7,7 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
set(:user) { create(:user) }
let(:pipeline) do
- build(:ci_pipeline_with_one_job, project: project,
- ref: 'master',
- user: user)
+ build(:ci_pipeline, project: project, ref: 'master', user: user)
end
let(:command) do
@@ -22,6 +20,14 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
let(:step) { described_class.new(pipeline, command) }
+ let(:config) do
+ { rspec: { script: 'rspec' } }
+ end
+
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump(config))
+ end
+
context 'when pipeline doesn not have seeds block' do
before do
step.perform!
@@ -59,10 +65,6 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
} }
end
- let(:pipeline) do
- build(:ci_pipeline, project: project, config: config)
- end
-
before do
step.perform!
end
@@ -202,10 +204,6 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } }
end
- let(:pipeline) do
- build(:ci_pipeline, ref: 'master', project: project, config: config)
- end
-
it_behaves_like 'a correct pipeline'
context 'when variables expression is specified' do
diff --git a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
index 7c1c016b4bb..af0f4d68150 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
@@ -6,13 +6,17 @@ describe Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do
let(:project) { create(:project, :repository) }
let(:pipeline) do
- build(:ci_pipeline_with_one_job, project: project, ref: 'master')
+ build(:ci_pipeline, project: project)
end
let(:command) do
double(:command, project: project, chat_data: { command: 'echo' })
end
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump(rspec: { script: 'rspec' }))
+ end
+
describe '#perform!' do
it 'removes unwanted jobs for chat pipelines' do
allow(pipeline).to receive(:chat?).and_return(true)
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
index e23aa09d881..ed3ce6760a3 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
@@ -13,11 +13,13 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
save_incompleted: true)
end
+ let(:pipeline) do
+ build(:ci_pipeline, project: project)
+ end
+
let!(:step) { described_class.new(pipeline, command) }
- before do
- step.perform!
- end
+ subject { step.perform! }
context 'when pipeline has no YAML configuration' do
let(:pipeline) do
@@ -25,18 +27,23 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
end
it 'appends errors about missing configuration' do
+ subject
+
expect(pipeline.errors.to_a)
.to include 'Missing .gitlab-ci.yml file'
end
it 'breaks the chain' do
+ subject
+
expect(step.break?).to be true
end
end
context 'when YAML configuration contains errors' do
- let(:pipeline) do
- build(:ci_pipeline, project: project, config: 'invalid YAML')
+ before do
+ stub_ci_pipeline_yaml_file('invalid YAML')
+ subject
end
it 'appends errors about YAML errors' do
@@ -56,10 +63,14 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
end
it 'fails the pipeline' do
+ subject
+
expect(pipeline.reload).to be_failed
end
it 'sets a config error failure reason' do
+ subject
+
expect(pipeline.reload.config_error?).to eq true
end
end
@@ -72,6 +83,8 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
end
it 'does not drop pipeline' do
+ subject
+
expect(pipeline).not_to be_failed
expect(pipeline).not_to be_persisted
end
@@ -79,17 +92,15 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
end
context 'when pipeline contains configuration validation errors' do
- let(:config) do
- {
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump({
rspec: {
before_script: 10,
script: 'ls -al'
}
- }
- end
+ }))
- let(:pipeline) do
- build(:ci_pipeline, project: project, config: config)
+ subject
end
it 'appends configuration validation errors to pipeline errors' do
@@ -103,8 +114,13 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
end
context 'when pipeline is correct and complete' do
- let(:pipeline) do
- build(:ci_pipeline_with_one_job, project: project)
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump({
+ rspec: {
+ script: 'rspec'
+ }
+ }))
+ subject
end
it 'does not invalidate the pipeline' do
@@ -119,6 +135,7 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
context 'when pipeline source is merge request' do
before do
stub_ci_pipeline_yaml_file(YAML.dump(config))
+ subject
end
let(:pipeline) { build_stubbed(:ci_pipeline, project: project) }
diff --git a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
index 934e676d020..b190a1007a0 100644
--- a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+++ b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
@@ -132,10 +132,6 @@ describe Gitlab::ImportExport::FastHashSerializer do
end
it 'has no when YML attributes but only the DB column' do
- allow_any_instance_of(Ci::Pipeline)
- .to receive(:ci_yaml_file)
- .and_return(File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
-
expect_any_instance_of(Gitlab::Ci::YamlProcessor).not_to receive(:build_attributes)
subject
diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
index ff46e062a5d..97d8b155826 100644
--- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
@@ -203,7 +203,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
end
it 'has no when YML attributes but only the DB column' do
- allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
expect_any_instance_of(Gitlab::Ci::YamlProcessor).not_to receive(:build_attributes)
saved_project_json
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 0ad196bd050..f01d89b35e2 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -17,6 +17,9 @@ describe Gitlab::UsageData do
create(:service, project: projects[0], type: 'SlackSlashCommandsService', active: true)
create(:service, project: projects[1], type: 'SlackService', active: true)
create(:service, project: projects[2], type: 'SlackService', active: true)
+ create(:service, project: projects[2], type: 'MattermostService', active: true)
+ create(:service, project: projects[2], type: 'JenkinsService', active: true)
+ create(:service, project: projects[2], type: 'CustomIssueTrackerService', active: true)
create(:project_error_tracking_setting, project: projects[0])
create(:project_error_tracking_setting, project: projects[1], enabled: false)
create_list(:issue, 4, project: projects[0])
@@ -157,6 +160,9 @@ describe Gitlab::UsageData do
projects_jira_cloud_active
projects_slack_notifications_active
projects_slack_slash_active
+ projects_custom_issue_tracker_active
+ projects_jenkins_active
+ projects_mattermost_active
projects_prometheus_active
projects_with_repositories_enabled
projects_with_error_tracking_enabled
@@ -190,6 +196,9 @@ describe Gitlab::UsageData do
expect(count_data[:projects_jira_cloud_active]).to eq(2)
expect(count_data[:projects_slack_notifications_active]).to eq(2)
expect(count_data[:projects_slack_slash_active]).to eq(1)
+ expect(count_data[:projects_custom_issue_tracker_active]).to eq(1)
+ expect(count_data[:projects_jenkins_active]).to eq(1)
+ expect(count_data[:projects_mattermost_active]).to eq(1)
expect(count_data[:projects_with_repositories_enabled]).to eq(3)
expect(count_data[:projects_with_error_tracking_enabled]).to eq(1)
expect(count_data[:issues_with_associated_zoom_link]).to eq(2)