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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 18:09:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 18:09:56 +0300
commitc08d9c22569d1c9e7c7737e183969593394133d9 (patch)
tree8ce1722f852f8921656080e04f6c9e16fa71ddb5 /spec/lib
parent546ddc3f6ac96fdf09934390a938bb391d07dc94 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb70
-rw-r--r--spec/lib/gitlab/jira_import/issue_serializer_spec.rb105
2 files changed, 158 insertions, 17 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index 62adba4319e..0b34e887716 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -1647,6 +1647,48 @@ module Gitlab
it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /is not defined in prior stages/) }
end
+
+ context 'when trigger job includes artifact generated by a dependency' do
+ context 'when dependency is defined in previous stages' do
+ let(:config) do
+ {
+ build1: { stage: 'build', script: 'test' },
+ test1: { stage: 'test', trigger: {
+ include: [{ job: 'build1', artifact: 'generated.yml' }]
+ } }
+ }
+ end
+
+ it { expect { subject }.not_to raise_error }
+ end
+
+ context 'when dependency is defined in later stages' do
+ let(:config) do
+ {
+ build1: { stage: 'build', script: 'test' },
+ test1: { stage: 'test', trigger: {
+ include: [{ job: 'deploy1', artifact: 'generated.yml' }]
+ } },
+ deploy1: { stage: 'deploy', script: 'test' }
+ }
+ end
+
+ it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /is not defined in prior stages/) }
+ end
+
+ context 'when dependency is not defined' do
+ let(:config) do
+ {
+ build1: { stage: 'build', script: 'test' },
+ test1: { stage: 'test', trigger: {
+ include: [{ job: 'non-existent', artifact: 'generated.yml' }]
+ } }
+ }
+ end
+
+ it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /undefined dependency: non-existent/) }
+ end
+ end
end
describe "Job Needs" do
@@ -2052,6 +2094,34 @@ module Gitlab
end
end
+ describe 'with trigger:include' do
+ context 'when artifact and job are specified' do
+ let(:config) do
+ YAML.dump({
+ build1: { stage: 'build', script: 'test' },
+ test1: { stage: 'test', trigger: {
+ include: [{ artifact: 'generated.yml', job: 'build1' }]
+ } }
+ })
+ end
+
+ it { expect { subject }.not_to raise_error }
+ end
+
+ context 'when artifact is specified without job' do
+ let(:config) do
+ YAML.dump({
+ build1: { stage: 'build', script: 'test' },
+ test1: { stage: 'test', trigger: {
+ include: [{ artifact: 'generated.yml' }]
+ } }
+ })
+ end
+
+ it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /must specify the job where to fetch the artifact from/) }
+ end
+ end
+
describe "Error handling" do
it "fails to parse YAML" do
expect do
diff --git a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb
index 03631a3e941..808ed6ee2fa 100644
--- a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb
+++ b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb
@@ -14,6 +14,29 @@ describe Gitlab::JiraImport::IssueSerializer do
let(:updated_at) { '2020-01-10 20:00:00' }
let(:assignee) { double(displayName: 'Solver') }
let(:jira_status) { 'new' }
+
+ let(:parent_field) do
+ { 'key' => 'FOO-2', 'id' => '1050', 'fields' => { 'summary' => 'parent issue FOO' } }
+ end
+ let(:issue_type_field) { { 'name' => 'Task' } }
+ let(:fix_versions_field) { [{ 'name' => '1.0' }, { 'name' => '1.1' }] }
+ let(:priority_field) { { 'name' => 'Medium' } }
+ let(:labels_field) { %w(bug backend) }
+ let(:environment_field) { 'staging' }
+ let(:duedate_field) { '2020-03-01' }
+
+ let(:fields) do
+ {
+ 'parent' => parent_field,
+ 'issuetype' => issue_type_field,
+ 'fixVersions' => fix_versions_field,
+ 'priority' => priority_field,
+ 'labels' => labels_field,
+ 'environment' => environment_field,
+ 'duedate' => duedate_field
+ }
+ end
+
let(:jira_issue) do
double(
id: '1234',
@@ -24,11 +47,15 @@ describe Gitlab::JiraImport::IssueSerializer do
updated: updated_at,
assignee: assignee,
reporter: double(displayName: 'Reporter'),
- status: double(statusCategory: { 'key' => jira_status })
+ status: double(statusCategory: { 'key' => jira_status }),
+ fields: fields
)
end
+
let(:params) { { iid: iid } }
+ subject { described_class.new(project, jira_issue, params).execute }
+
let(:expected_description) do
<<~MD
*Created by: Reporter*
@@ -36,11 +63,21 @@ describe Gitlab::JiraImport::IssueSerializer do
*Assigned to: Solver*
basic description
+
+ ---
+
+ **Issue metadata**
+
+ - Issue type: Task
+ - Priority: Medium
+ - Labels: bug, backend
+ - Environment: staging
+ - Due date: 2020-03-01
+ - Parent issue: [FOO-2] parent issue FOO
+ - Fix versions: 1.0, 1.1
MD
end
- subject { described_class.new(project, jira_issue, params).execute }
-
context 'attributes setting' do
it 'sets the basic attributes' do
expect(subject).to eq(
@@ -54,6 +91,54 @@ describe Gitlab::JiraImport::IssueSerializer do
author_id: project.creator_id
)
end
+
+ context 'when some metadata fields are missing' do
+ let(:assignee) { nil }
+ let(:parent_field) { nil }
+ let(:fix_versions_field) { [] }
+ let(:labels_field) { [] }
+ let(:environment_field) { nil }
+ let(:duedate_field) { '2020-03-01' }
+
+ it 'skips the missing fields' do
+ expected_description = <<~MD
+ *Created by: Reporter*
+
+ basic description
+
+ ---
+
+ **Issue metadata**
+
+ - Issue type: Task
+ - Priority: Medium
+ - Due date: 2020-03-01
+ MD
+
+ expect(subject[:description]).to eq(expected_description.strip)
+ end
+ end
+
+ context 'when all metadata fields are missing' do
+ let(:assignee) { nil }
+ let(:parent_field) { nil }
+ let(:issue_type_field) { nil }
+ let(:fix_versions_field) { [] }
+ let(:priority_field) { nil }
+ let(:labels_field) { [] }
+ let(:environment_field) { nil }
+ let(:duedate_field) { nil }
+
+ it 'skips the whole metadata secction' do
+ expected_description = <<~MD
+ *Created by: Reporter*
+
+ basic description
+ MD
+
+ expect(subject[:description]).to eq(expected_description.strip)
+ end
+ end
end
context 'with done status' do
@@ -64,20 +149,6 @@ describe Gitlab::JiraImport::IssueSerializer do
end
end
- context 'without the assignee' do
- let(:assignee) { nil }
-
- it 'does not include assignee in the description' do
- expected_description = <<~MD
- *Created by: Reporter*
-
- basic description
- MD
-
- expect(subject[:description]).to eq(expected_description.strip)
- end
- end
-
context 'without the iid' do
let(:params) { {} }