diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 15:10:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 15:10:14 +0300 |
commit | a27b8a5c104f492e4b0abac4c84385a615c4f6ba (patch) | |
tree | 3ec1a2cc06312b1999ce405905ab7881f68927d2 /spec/lib | |
parent | 635d82b15d83a88a2d073fbf3bb56f6ff626020f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
5 files changed, 191 insertions, 51 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/product/matrix_spec.rb b/spec/lib/gitlab/ci/config/entry/product/matrix_spec.rb index 39697884e3b..3388ae0af2f 100644 --- a/spec/lib/gitlab/ci/config/entry/product/matrix_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/product/matrix_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'spec_helper' require_dependency 'active_model' RSpec.describe ::Gitlab::Ci::Config::Entry::Product::Matrix do @@ -46,33 +46,140 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Product::Matrix do end end - context 'when entry config has only one variable' do - let(:config) do - [ - { - 'VAR_1' => %w[test] - } - ] + context 'with one_dimensional_matrix feature flag enabled' do + before do + stub_feature_flags(one_dimensional_matrix: true) + matrix.compose! end - describe '#valid?' do - it { is_expected.not_to be_valid } - end + context 'when entry config has only one variable with multiple values' do + let(:config) do + [ + { + 'VAR_1' => %w[build test] + } + ] + end - describe '#errors' do - it 'returns error about too many jobs' do - expect(matrix.errors) - .to include('variables config requires at least 2 items') + describe '#valid?' do + it { is_expected.to be_valid } + end + + describe '#errors' do + it 'returns no errors' do + expect(matrix.errors) + .to be_empty + end + end + + describe '#value' do + before do + matrix.compose! + end + + it 'returns the value without raising an error' do + expect(matrix.value).to eq([{ 'VAR_1' => %w[build test] }]) + end end + + context 'when entry config has only one variable with one value' do + let(:config) do + [ + { + 'VAR_1' => %w[test] + } + ] + end + + describe '#valid?' do + it { is_expected.to be_valid } + end + + describe '#errors' do + it 'returns no errors' do + expect(matrix.errors) + .to be_empty + end + end + + describe '#value' do + before do + matrix.compose! + end + + it 'returns the value without raising an error' do + expect(matrix.value).to eq([{ 'VAR_1' => %w[test] }]) + end + end + end + end + end + + context 'with one_dimensional_matrix feature flag disabled' do + before do + stub_feature_flags(one_dimensional_matrix: false) + matrix.compose! end - describe '#value' do - before do - matrix.compose! + context 'when entry config has only one variable with multiple values' do + let(:config) do + [ + { + 'VAR_1' => %w[build test] + } + ] end - it 'returns the value without raising an error' do - expect(matrix.value).to eq([{ 'VAR_1' => ['test'] }]) + describe '#valid?' do + it { is_expected.not_to be_valid } + end + + describe '#errors' do + it 'returns error about too many jobs' do + expect(matrix.errors) + .to include('variables config requires at least 2 items') + end + end + + describe '#value' do + before do + matrix.compose! + end + + it 'returns the value without raising an error' do + expect(matrix.value).to eq([{ 'VAR_1' => %w[build test] }]) + end + end + + context 'when entry config has only one variable with one value' do + let(:config) do + [ + { + 'VAR_1' => %w[test] + } + ] + end + + describe '#valid?' do + it { is_expected.not_to be_valid } + end + + describe '#errors' do + it 'returns no errors' do + expect(matrix.errors) + .to include('variables config requires at least 2 items') + end + end + + describe '#value' do + before do + matrix.compose! + end + + it 'returns the value without raising an error' do + expect(matrix.value).to eq([{ 'VAR_1' => %w[test] }]) + end + end end end end diff --git a/spec/lib/gitlab/ci/config/entry/product/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/product/variables_spec.rb index 230b001d620..407efb438b5 100644 --- a/spec/lib/gitlab/ci/config/entry/product/variables_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/product/variables_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -require 'fast_spec_helper' +# After Feature one_dimensional_matrix is removed, this can be changed back to fast_spec_helper +require 'spec_helper' require_dependency 'active_model' RSpec.describe Gitlab::Ci::Config::Entry::Product::Variables do @@ -45,43 +46,71 @@ RSpec.describe Gitlab::Ci::Config::Entry::Product::Variables do end end - context 'when entry value is not correct' do - shared_examples 'invalid variables' do |message| - describe '#errors' do - it 'saves errors' do - expect(entry.errors).to include(message) - end + context 'with one_dimensional_matrix feature flag enabled' do + context 'with only one variable' do + before do + stub_feature_flags(one_dimensional_matrix: true) end + let(:config) { { VAR: 'test' } } describe '#valid?' do - it 'is not valid' do - expect(entry).not_to be_valid + it 'is valid' do + expect(entry).to be_valid + end + end + + describe '#errors' do + it 'does not append errors' do + expect(entry.errors).to be_empty end end end + end - context 'with array' do - let(:config) { [:VAR, 'test'] } + context 'with one_dimensional_matrix feature flag disabled' do + context 'when entry value is not correct' do + before do + stub_feature_flags(one_dimensional_matrix: false) + end + shared_examples 'invalid variables' do |message| + describe '#errors' do + it 'saves errors' do + expect(entry.errors).to include(message) + end + end - it_behaves_like 'invalid variables', /should be a hash of key value pairs/ - end + describe '#valid?' do + it 'is not valid' do + expect(entry).not_to be_valid + end + end + end - context 'with empty array' do - let(:config) { { VAR: 'test', VAR2: [] } } + context 'with array' do + let(:config) { [:VAR, 'test'] } - it_behaves_like 'invalid variables', /should be a hash of key value pairs/ - end + it_behaves_like 'invalid variables', /should be a hash of key value pairs/ + end - context 'with nested array' do - let(:config) { { VAR: 'test', VAR2: [1, [2]] } } + context 'with empty array' do + let(:config) { { VAR: 'test', VAR2: [] } } - it_behaves_like 'invalid variables', /should be a hash of key value pairs/ - end + it_behaves_like 'invalid variables', /should be a hash of key value pairs/ + end - context 'with only one variable' do - let(:config) { { VAR: 'test' } } + context 'with nested array' do + let(:config) { { VAR: 'test', VAR2: [1, [2]] } } + + it_behaves_like 'invalid variables', /should be a hash of key value pairs/ + end - it_behaves_like 'invalid variables', /variables config requires at least 2 items/ + context 'with one_dimensional_matrix feature flag disabled' do + context 'with only one variable' do + let(:config) { { VAR: 'test' } } + + it_behaves_like 'invalid variables', /variables config requires at least 2 items/ + end + end end end end diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb index bd60c24859c..72a66b0451e 100644 --- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb @@ -120,7 +120,7 @@ RSpec.describe Gitlab::Diff::FileCollection::MergeRequestDiffBatch do described_class.new(merge_request.merge_request_diff, batch_page, batch_size, - collection_default_args) + **collection_default_args) end end diff --git a/spec/lib/gitlab/lfs/client_spec.rb b/spec/lib/gitlab/lfs/client_spec.rb index b34f2ac0d80..14af9d02cb5 100644 --- a/spec/lib/gitlab/lfs/client_spec.rb +++ b/spec/lib/gitlab/lfs/client_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::Lfs::Client do let(:password) { 'password' } let(:credentials) { { user: username, password: password, auth_method: 'password' } } let(:git_lfs_content_type) { 'application/vnd.git-lfs+json' } + let(:git_lfs_user_agent) { "GitLab #{Gitlab::VERSION} LFS client" } let(:basic_auth_headers) do { 'Authorization' => "Basic #{Base64.strict_encode64("#{username}:#{password}")}" } @@ -91,7 +92,8 @@ RSpec.describe Gitlab::Lfs::Client do headers = { 'Accept' => git_lfs_content_type, - 'Content-Type' => git_lfs_content_type + 'Content-Type' => git_lfs_content_type, + 'User-Agent' => git_lfs_user_agent }.merge(headers) stub_request(:post, base_url + '/info/lfs/objects/batch').with(body: body, headers: headers) @@ -156,7 +158,8 @@ RSpec.describe Gitlab::Lfs::Client do def stub_upload(object:, headers:) headers = { 'Content-Type' => 'application/octet-stream', - 'Content-Length' => object.size.to_s + 'Content-Length' => object.size.to_s, + 'User-Agent' => git_lfs_user_agent }.merge(headers) stub_request(:put, upload_action['href']).with( @@ -209,7 +212,8 @@ RSpec.describe Gitlab::Lfs::Client do def stub_verify(object:, headers:) headers = { 'Accept' => git_lfs_content_type, - 'Content-Type' => git_lfs_content_type + 'Content-Type' => git_lfs_content_type, + 'User-Agent' => git_lfs_user_agent }.merge(headers) stub_request(:post, verify_action['href']).with( diff --git a/spec/lib/gitlab/project_template_spec.rb b/spec/lib/gitlab/project_template_spec.rb index fa45c605b1b..98bd2efdbc6 100644 --- a/spec/lib/gitlab/project_template_spec.rb +++ b/spec/lib/gitlab/project_template_spec.rb @@ -8,9 +8,9 @@ RSpec.describe Gitlab::ProjectTemplate do expected = %w[ rails spring express iosswift dotnetcore android gomicro gatsby hugo jekyll plainhtml gitbook - hexo sse_middleman nfhugo nfjekyll nfplainhtml - nfgitbook nfhexo salesforcedx serverless_framework - jsonnet cluster_management + hexo sse_middleman gitpod_spring_petclinic nfhugo + nfjekyll nfplainhtml nfgitbook nfhexo salesforcedx + serverless_framework jsonnet cluster_management ] expect(described_class.all).to be_an(Array) |