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-11-13 15:06:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-13 15:06:22 +0300
commit4e516dbff9767a35677fdc4a6e39005b4b564376 (patch)
tree7c650b30777b8e7f72cafb186e9446a50d3fa3be /spec/models
parent4f01ac5ba0bf72427ed4fef9b229d056dbb60e89 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb40
-rw-r--r--spec/models/merge_request_spec.rb8
-rw-r--r--spec/models/service_spec.rb20
3 files changed, 51 insertions, 17 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 9295bb993ce..1242cf05a59 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -980,7 +980,11 @@ describe Ci::Pipeline, :mailer do
describe 'pipeline stages' do
describe '#stage_seeds' do
- let(:pipeline) { build(:ci_pipeline, config: config) }
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump(config))
+ end
+
+ let(:pipeline) { build(:ci_pipeline) }
let(:config) { { rspec: { script: 'rake' } } }
it 'returns preseeded stage seeds object' do
@@ -1010,7 +1014,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)
end
let(:config) do
@@ -1028,7 +1032,7 @@ describe Ci::Pipeline, :mailer do
end
context 'when source policy is specified' do
- let(:pipeline) { build(:ci_pipeline, source: :schedule, config: config) }
+ let(:pipeline) { build(:ci_pipeline, source: :schedule) }
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['triggers'] },
@@ -1060,7 +1064,7 @@ describe Ci::Pipeline, :mailer do
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
+ let(:pipeline) { build(:ci_pipeline, project: project) }
it 'returns seeds for kubernetes dependent job' do
seeds = pipeline.stage_seeds
@@ -1098,6 +1102,10 @@ describe Ci::Pipeline, :mailer do
end
describe '#seeds_size' do
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump(config))
+ end
+
context 'when refs policy is specified' do
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['master'] },
@@ -1105,7 +1113,7 @@ describe Ci::Pipeline, :mailer do
end
let(:pipeline) do
- build(:ci_pipeline, ref: 'feature', tag: true, config: config)
+ build(:ci_pipeline, ref: 'feature', tag: true)
end
it 'returns real seeds size' do
@@ -2886,21 +2894,25 @@ describe Ci::Pipeline, :mailer do
end
describe '#has_yaml_errors?' do
+ before do
+ stub_ci_pipeline_yaml_file(YAML.dump(config))
+ end
+
+ let(:pipeline) { create(:ci_pipeline) }
+
context 'when pipeline has errors' do
- let(:pipeline) do
- create(:ci_pipeline, config: { rspec: nil })
- end
+ let(:config) { { rspec: nil } }
it 'contains yaml errors' do
+ pipeline.config_processor
+
expect(pipeline).to have_yaml_errors
expect(pipeline.yaml_errors).to include('contains unknown keys')
end
end
context 'when pipeline has undefined error' do
- let(:pipeline) do
- create(:ci_pipeline, config: {})
- end
+ let(:config) { double(:config) }
it 'contains yaml errors' do
expect(::Gitlab::Ci::YamlProcessor).to receive(:new)
@@ -2910,14 +2922,16 @@ describe Ci::Pipeline, :mailer do
.with(be_a(RuntimeError), anything)
.and_call_original
+ pipeline.config_processor
+
expect(pipeline).to have_yaml_errors
expect(pipeline.yaml_errors).to include('Undefined error')
end
end
context 'when pipeline does not have errors' do
- let(:pipeline) do
- create(:ci_pipeline, config: { rspec: { script: 'rake test' } })
+ let(:config) do
+ { rspec: { script: 'rake test' } }
end
it 'does not contain yaml errors' do
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index adf178330f4..f775dfb87a2 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -2807,7 +2807,7 @@ describe MergeRequest do
describe '#mergeable_with_quick_action?' do
def create_pipeline(status)
- pipeline = create(:ci_pipeline_with_one_job,
+ pipeline = create(:ci_pipeline,
project: project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha,
@@ -2922,9 +2922,9 @@ describe MergeRequest do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
- let!(:first_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
- let!(:last_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
- let!(:last_pipeline_with_other_ref) { create(:ci_pipeline_without_jobs, pipeline_arguments.merge(ref: 'other')) }
+ let!(:first_pipeline) { create(:ci_pipeline, pipeline_arguments) }
+ let!(:last_pipeline) { create(:ci_pipeline, pipeline_arguments) }
+ let!(:last_pipeline_with_other_ref) { create(:ci_pipeline, pipeline_arguments.merge(ref: 'other')) }
it 'returns latest pipeline for the target branch' do
expect(merge_request.base_pipeline).to eq(last_pipeline)
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 64077b76f01..f58bcbebd67 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -15,6 +15,26 @@ describe Service do
end
describe 'Scopes' do
+ describe '.by_type' do
+ let!(:service1) { create(:jira_service) }
+ let!(:service2) { create(:jira_service) }
+ let!(:service3) { create(:redmine_service) }
+
+ subject { described_class.by_type(type) }
+
+ context 'when type is "JiraService"' do
+ let(:type) { 'JiraService' }
+
+ it { is_expected.to match_array([service1, service2]) }
+ end
+
+ context 'when type is "RedmineService"' do
+ let(:type) { 'RedmineService' }
+
+ it { is_expected.to match_array([service3]) }
+ end
+ end
+
describe '.confidential_note_hooks' do
it 'includes services where confidential_note_events is true' do
create(:service, active: true, confidential_note_events: true)