diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-13 21:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-13 21:08:47 +0300 |
commit | e689e858ede41a34b1e9132eba6a602632e6885e (patch) | |
tree | 57f173714a177a70aa6631d77f10d5628d42cd90 /spec/lib/gitlab | |
parent | 868e4e69bba7d3ddc2bf4899ee45d6c377a8e536 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/artifacts_spec.rb | 50 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 14 |
3 files changed, 75 insertions, 7 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index 53469159110..8cfd07df777 100644 --- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb @@ -124,5 +124,55 @@ describe Gitlab::Ci::Config::Entry::Artifacts do end end end + + describe 'excluded artifacts' do + context 'when configuration is valid and the feature is enabled' do + before do + stub_feature_flags(ci_artifacts_exclude: true) + end + + context 'when configuration is valid' do + let(:config) { { untracked: true, exclude: ['some/directory/'] } } + + it 'correctly parses the configuration' do + expect(entry).to be_valid + expect(entry.value).to eq config + end + end + + context 'when configuration is not valid' do + let(:config) { { untracked: true, exclude: 1234 } } + + it 'returns an error' do + expect(entry).not_to be_valid + expect(entry.errors) + .to include 'artifacts exclude should be an array of strings' + end + end + end + + context 'when artifacts/exclude feature is disabled' do + before do + stub_feature_flags(ci_artifacts_exclude: false) + end + + context 'when configuration has been provided' do + let(:config) { { untracked: true, exclude: ['some/directory/'] } } + + it 'returns an error' do + expect(entry).not_to be_valid + expect(entry.errors).to include 'artifacts exclude feature is disabled' + end + end + + context 'when configuration is not present' do + let(:config) { { untracked: true } } + + it 'is a valid configuration' do + expect(entry).to be_valid + end + end + end + end end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 969a674a308..c93bb901981 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1364,6 +1364,24 @@ module Gitlab expect { described_class.new(config) }.to raise_error(described_class::ValidationError) end + + it 'populates a build options with complete artifacts configuration' do + stub_feature_flags(ci_artifacts_exclude: true) + + config = <<~YAML + test: + script: echo "Hello World" + artifacts: + paths: + - my/test + exclude: + - my/test/something + YAML + + attributes = Gitlab::Ci::YamlProcessor.new(config).build_attributes('test') + + expect(attributes.dig(*%i[options artifacts exclude])).to eq(%w[my/test/something]) + end end describe "release" do diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 73b9dcc5bf9..9ed4db673a6 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -647,7 +647,7 @@ describe Gitlab::Database::MigrationHelpers do expect(model).to receive(:update_column_in_batches) .with(:projects, :foo, 10) - expect(model).not_to receive(:add_not_null_constraint) + expect(model).not_to receive(:change_column_null) model.add_column_with_default(:projects, :foo, :integer, default: 10, @@ -658,8 +658,8 @@ describe Gitlab::Database::MigrationHelpers do expect(model).to receive(:update_column_in_batches) .with(:projects, :foo, 10) - expect(model).to receive(:add_not_null_constraint) - .with(:projects, :foo) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) model.add_column_with_default(:projects, :foo, :integer, default: 10) end @@ -678,8 +678,8 @@ describe Gitlab::Database::MigrationHelpers do end it 'removes the added column whenever changing a column NULL constraint fails' do - expect(model).to receive(:add_not_null_constraint) - .with(:projects, :foo) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) .and_raise(ActiveRecord::ActiveRecordError) expect(model).to receive(:remove_column) @@ -699,7 +699,7 @@ describe Gitlab::Database::MigrationHelpers do allow(model).to receive(:transaction).and_yield allow(model).to receive(:column_for).with(:user_details, :foo).and_return(column) allow(model).to receive(:update_column_in_batches).with(:user_details, :foo, 10, batch_column_name: :user_id) - allow(model).to receive(:add_not_null_constraint).with(:user_details, :foo) + allow(model).to receive(:change_column_null).with(:user_details, :foo, false) allow(model).to receive(:change_column_default).with(:user_details, :foo, 10) expect(model).to receive(:add_column) @@ -721,7 +721,7 @@ describe Gitlab::Database::MigrationHelpers do allow(model).to receive(:transaction).and_yield allow(model).to receive(:column_for).with(:projects, :foo).and_return(column) allow(model).to receive(:update_column_in_batches).with(:projects, :foo, 10) - allow(model).to receive(:add_not_null_constraint).with(:projects, :foo) + allow(model).to receive(:change_column_null).with(:projects, :foo, false) allow(model).to receive(:change_column_default).with(:projects, :foo, 10) expect(model).to receive(:add_column) |