diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/gitlab/ci | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/gitlab/ci')
204 files changed, 949 insertions, 323 deletions
diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb index ee789995bc2..f29a39e4e66 100644 --- a/spec/lib/gitlab/ci/ansi2html_spec.rb +++ b/spec/lib/gitlab/ci/ansi2html_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Ansi2html do +RSpec.describe Gitlab::Ci::Ansi2html do subject { described_class } it "prints non-ansi as-is" do diff --git a/spec/lib/gitlab/ci/ansi2json/line_spec.rb b/spec/lib/gitlab/ci/ansi2json/line_spec.rb index 4b5c3f9489e..8b1cd812a70 100644 --- a/spec/lib/gitlab/ci/ansi2json/line_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json/line_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Ansi2json::Line do +RSpec.describe Gitlab::Ci::Ansi2json::Line do let(:offset) { 0 } let(:style) { Gitlab::Ci::Ansi2json::Style.new } diff --git a/spec/lib/gitlab/ci/ansi2json/parser_spec.rb b/spec/lib/gitlab/ci/ansi2json/parser_spec.rb index e161e74c1ff..cf93ebe0721 100644 --- a/spec/lib/gitlab/ci/ansi2json/parser_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json/parser_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # The rest of the specs for this class are covered in style_spec.rb -describe Gitlab::Ci::Ansi2json::Parser do +RSpec.describe Gitlab::Ci::Ansi2json::Parser do subject { described_class } describe 'bold?' do diff --git a/spec/lib/gitlab/ci/ansi2json/result_spec.rb b/spec/lib/gitlab/ci/ansi2json/result_spec.rb index 5b7b5481400..31c0da95f0a 100644 --- a/spec/lib/gitlab/ci/ansi2json/result_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json/result_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Ansi2json::Result do +RSpec.describe Gitlab::Ci::Ansi2json::Result do let(:stream) { StringIO.new('hello') } let(:state) { Gitlab::Ci::Ansi2json::State.new(nil, stream.size) } let(:offset) { 0 } diff --git a/spec/lib/gitlab/ci/ansi2json/style_spec.rb b/spec/lib/gitlab/ci/ansi2json/style_spec.rb index ad05aa03e83..d27a642ecf3 100644 --- a/spec/lib/gitlab/ci/ansi2json/style_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json/style_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Ansi2json::Style do +RSpec.describe Gitlab::Ci::Ansi2json::Style do describe '#set?' do subject { described_class.new(params).set? } diff --git a/spec/lib/gitlab/ci/ansi2json_spec.rb b/spec/lib/gitlab/ci/ansi2json_spec.rb index 124379fa321..cb6949fddc2 100644 --- a/spec/lib/gitlab/ci/ansi2json_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Ansi2json do +RSpec.describe Gitlab::Ci::Ansi2json do subject { described_class } describe 'lines' do diff --git a/spec/lib/gitlab/ci/artifact_file_reader_spec.rb b/spec/lib/gitlab/ci/artifact_file_reader_spec.rb index 04017b9ae3e..e982f0eb015 100644 --- a/spec/lib/gitlab/ci/artifact_file_reader_spec.rb +++ b/spec/lib/gitlab/ci/artifact_file_reader_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::ArtifactFileReader do +RSpec.describe Gitlab::Ci::ArtifactFileReader do let(:job) { create(:ci_build) } let(:path) { 'generated.yml' } # included in the ci_build_artifacts.zip diff --git a/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb index cec3e70bb9f..98f909a0ed0 100644 --- a/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::Adapters::GzipStream do +RSpec.describe Gitlab::Ci::Build::Artifacts::Adapters::GzipStream do describe '#initialize' do context 'when stream is passed' do let(:stream) { File.open(expand_fixture_path('junit/junit.xml.gz'), 'rb') } diff --git a/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb index 66a234232e1..badff972e60 100644 --- a/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::Adapters::RawStream do +RSpec.describe Gitlab::Ci::Build::Artifacts::Adapters::RawStream do describe '#initialize' do context 'when stream is passed' do let(:stream) { File.open(expand_fixture_path('junit/junit.xml'), 'rb') } diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb index 7a413a7aeac..c8ace28108b 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do +RSpec.describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do let(:entries) do { 'path/' => {}, 'path/dir_1/' => {}, diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index bfa65c66b33..77b8aa1d591 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::Metadata do +RSpec.describe Gitlab::Ci::Build::Artifacts::Metadata do def metadata(path = '', **opts) described_class.new(metadata_file_stream, path, **opts) end diff --git a/spec/lib/gitlab/ci/build/artifacts/path_spec.rb b/spec/lib/gitlab/ci/build/artifacts/path_spec.rb index 7bbef0f5197..27b7dac2ae4 100644 --- a/spec/lib/gitlab/ci/build/artifacts/path_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/path_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::Path do +RSpec.describe Gitlab::Ci::Build::Artifacts::Path do describe '#valid?' do context 'when path contains a zero character' do it 'is not valid' do diff --git a/spec/lib/gitlab/ci/build/context/build_spec.rb b/spec/lib/gitlab/ci/build/context/build_spec.rb index 1b73b9a083d..61ca8e759b5 100644 --- a/spec/lib/gitlab/ci/build/context/build_spec.rb +++ b/spec/lib/gitlab/ci/build/context/build_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Context::Build do +RSpec.describe Gitlab::Ci::Build::Context::Build do let(:pipeline) { create(:ci_pipeline) } let(:seed_attributes) { { 'name' => 'some-job' } } diff --git a/spec/lib/gitlab/ci/build/context/global_spec.rb b/spec/lib/gitlab/ci/build/context/global_spec.rb index 65cc41ed3f9..7394708f9b6 100644 --- a/spec/lib/gitlab/ci/build/context/global_spec.rb +++ b/spec/lib/gitlab/ci/build/context/global_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Context::Global do +RSpec.describe Gitlab::Ci::Build::Context::Global do let(:pipeline) { create(:ci_pipeline) } let(:yaml_variables) { {} } diff --git a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb index 159f89f4985..613d360f78d 100644 --- a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb +++ b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Credentials::Factory do +RSpec.describe Gitlab::Ci::Build::Credentials::Factory do let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) } subject { described_class.new(build).create! } diff --git a/spec/lib/gitlab/ci/build/credentials/registry_spec.rb b/spec/lib/gitlab/ci/build/credentials/registry_spec.rb index 552580dcbbe..c0a76973f60 100644 --- a/spec/lib/gitlab/ci/build/credentials/registry_spec.rb +++ b/spec/lib/gitlab/ci/build/credentials/registry_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Credentials::Registry do +RSpec.describe Gitlab::Ci::Build::Credentials::Registry do let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) } let(:registry_url) { 'registry.example.com:5005' } diff --git a/spec/lib/gitlab/ci/build/image_spec.rb b/spec/lib/gitlab/ci/build/image_spec.rb index 4f7cfc9783a..71cd57d317c 100644 --- a/spec/lib/gitlab/ci/build/image_spec.rb +++ b/spec/lib/gitlab/ci/build/image_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Image do +RSpec.describe Gitlab::Ci::Build::Image do let(:job) { create(:ci_build, :no_options) } describe '#from_image' do diff --git a/spec/lib/gitlab/ci/build/policy/changes_spec.rb b/spec/lib/gitlab/ci/build/policy/changes_spec.rb index 07f52605929..016730e01cd 100644 --- a/spec/lib/gitlab/ci/build/policy/changes_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/changes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Policy::Changes do +RSpec.describe Gitlab::Ci::Build::Policy::Changes do let_it_be(:project) { create(:project) } describe '#satisfied_by?' do diff --git a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb index 6d96bdc30c7..81c0b76b453 100644 --- a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Policy::Kubernetes do +RSpec.describe Gitlab::Ci::Build::Policy::Kubernetes do let(:pipeline) { create(:ci_pipeline, project: project) } context 'when kubernetes service is active' do diff --git a/spec/lib/gitlab/ci/build/policy/refs_spec.rb b/spec/lib/gitlab/ci/build/policy/refs_spec.rb index c32fdc5c72e..7fd51102d71 100644 --- a/spec/lib/gitlab/ci/build/policy/refs_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/refs_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Policy::Refs do +RSpec.describe Gitlab::Ci::Build::Policy::Refs do describe '#satisfied_by?' do context 'when matching ref' do let(:pipeline) { build_stubbed(:ci_pipeline, ref: 'master') } diff --git a/spec/lib/gitlab/ci/build/policy/variables_spec.rb b/spec/lib/gitlab/ci/build/policy/variables_spec.rb index 0e75726b81c..f692aa6146e 100644 --- a/spec/lib/gitlab/ci/build/policy/variables_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/variables_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Policy::Variables do +RSpec.describe Gitlab::Ci::Build::Policy::Variables do let_it_be(:project) { create(:project) } let(:pipeline) do diff --git a/spec/lib/gitlab/ci/build/policy_spec.rb b/spec/lib/gitlab/ci/build/policy_spec.rb index 80d7b2e9dc8..b85b093fd03 100644 --- a/spec/lib/gitlab/ci/build/policy_spec.rb +++ b/spec/lib/gitlab/ci/build/policy_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Policy do +RSpec.describe Gitlab::Ci::Build::Policy do let(:policy) { spy('policy specification') } before do diff --git a/spec/lib/gitlab/ci/build/port_spec.rb b/spec/lib/gitlab/ci/build/port_spec.rb index 1413780dfa6..480418e0851 100644 --- a/spec/lib/gitlab/ci/build/port_spec.rb +++ b/spec/lib/gitlab/ci/build/port_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Port do +RSpec.describe Gitlab::Ci::Build::Port do subject { described_class.new(port) } context 'when port is defined as an integer' do diff --git a/spec/lib/gitlab/ci/build/prerequisite/factory_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/factory_spec.rb index 5187f99a441..a38ade4bfa5 100644 --- a/spec/lib/gitlab/ci/build/prerequisite/factory_spec.rb +++ b/spec/lib/gitlab/ci/build/prerequisite/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Prerequisite::Factory do +RSpec.describe Gitlab::Ci::Build::Prerequisite::Factory do let(:build) { create(:ci_build) } describe '.for_build' do diff --git a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb index 66240380edd..94c14cfa479 100644 --- a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb +++ b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do +RSpec.describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do describe '#unmet?' do let(:build) { create(:ci_build) } diff --git a/spec/lib/gitlab/ci/build/releaser_spec.rb b/spec/lib/gitlab/ci/build/releaser_spec.rb index 2f7bca777dd..fa5e90674a6 100644 --- a/spec/lib/gitlab/ci/build/releaser_spec.rb +++ b/spec/lib/gitlab/ci/build/releaser_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Releaser do +RSpec.describe Gitlab::Ci::Build::Releaser do subject { described_class.new(config: config[:release]).script } describe '#script' do @@ -13,13 +13,15 @@ describe Gitlab::Ci::Build::Releaser do name: 'Release $CI_COMMIT_SHA', description: 'Created using the release-cli $EXTRA_DESCRIPTION', tag_name: 'release-$CI_COMMIT_SHA', - ref: '$CI_COMMIT_SHA' + ref: '$CI_COMMIT_SHA', + milestones: %w[m1 m2 m3], + released_at: '2020-07-15T08:00:00Z' } } end it 'generates the script' do - expect(subject).to eq('release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA"') + expect(subject).to eq(['release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA" --released-at "2020-07-15T08:00:00Z" --milestone "m1" --milestone "m2" --milestone "m3"']) end end @@ -27,10 +29,12 @@ describe Gitlab::Ci::Build::Releaser do using RSpec::Parameterized::TableSyntax where(:node_name, :node_value, :result) do - 'name' | 'Release $CI_COMMIT_SHA' | 'release-cli create --name "Release $CI_COMMIT_SHA"' - 'description' | 'Release-cli $EXTRA_DESCRIPTION' | 'release-cli create --description "Release-cli $EXTRA_DESCRIPTION"' - 'tag_name' | 'release-$CI_COMMIT_SHA' | 'release-cli create --tag-name "release-$CI_COMMIT_SHA"' - 'ref' | '$CI_COMMIT_SHA' | 'release-cli create --ref "$CI_COMMIT_SHA"' + :name | 'Release $CI_COMMIT_SHA' | 'release-cli create --name "Release $CI_COMMIT_SHA"' + :description | 'Release-cli $EXTRA_DESCRIPTION' | 'release-cli create --description "Release-cli $EXTRA_DESCRIPTION"' + :tag_name | 'release-$CI_COMMIT_SHA' | 'release-cli create --tag-name "release-$CI_COMMIT_SHA"' + :ref | '$CI_COMMIT_SHA' | 'release-cli create --ref "$CI_COMMIT_SHA"' + :milestones | %w[m1 m2 m3] | 'release-cli create --milestone "m1" --milestone "m2" --milestone "m3"' + :released_at | '2020-07-15T08:00:00Z' | 'release-cli create --released-at "2020-07-15T08:00:00Z"' end with_them do @@ -43,7 +47,7 @@ describe Gitlab::Ci::Build::Releaser do end it 'generates the script' do - expect(subject).to eq(result) + expect(subject).to eq([result]) end end end diff --git a/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb b/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb index 076de3646b0..cf52f601006 100644 --- a/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb +++ b/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do +RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do describe '#satisfied_by?' do it_behaves_like 'a glob matching rule' do let(:pipeline) { build(:ci_pipeline) } diff --git a/spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb b/spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb index 10843a1435a..86dd5569a96 100644 --- a/spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb +++ b/spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Rules::Rule::Clause::Exists do +RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Exists do describe '#satisfied_by?' do let(:pipeline) { build(:ci_pipeline, project: project, sha: project.repository.head_commit.sha) } diff --git a/spec/lib/gitlab/ci/build/rules/rule_spec.rb b/spec/lib/gitlab/ci/build/rules/rule_spec.rb index 04cdaa9d0ae..5694cd5d0a0 100644 --- a/spec/lib/gitlab/ci/build/rules/rule_spec.rb +++ b/spec/lib/gitlab/ci/build/rules/rule_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Rules::Rule do +RSpec.describe Gitlab::Ci::Build::Rules::Rule do let(:seed) do double('build seed', to_resource: ci_build, diff --git a/spec/lib/gitlab/ci/build/rules_spec.rb b/spec/lib/gitlab/ci/build/rules_spec.rb index 31a9fa055e1..cbeae33fbcf 100644 --- a/spec/lib/gitlab/ci/build/rules_spec.rb +++ b/spec/lib/gitlab/ci/build/rules_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Rules do +RSpec.describe Gitlab::Ci::Build::Rules do let(:pipeline) { create(:ci_pipeline) } let(:ci_build) { build(:ci_build, pipeline: pipeline) } diff --git a/spec/lib/gitlab/ci/build/step_spec.rb b/spec/lib/gitlab/ci/build/step_spec.rb index 1cebda2cc7e..4b8f68b9fa8 100644 --- a/spec/lib/gitlab/ci/build/step_spec.rb +++ b/spec/lib/gitlab/ci/build/step_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Step do +RSpec.describe Gitlab::Ci::Build::Step do describe '#from_commands' do subject { described_class.from_commands(job) } @@ -62,7 +62,7 @@ describe Gitlab::Ci::Build::Step do let(:job) { create(:ci_build, :release_options) } it 'returns the release-cli command line' do - expect(subject.script).to eq("release-cli create --name \"Release $CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\" --tag-name \"release-$CI_COMMIT_SHA\" --ref \"$CI_COMMIT_SHA\"") + expect(subject.script).to eq(["release-cli create --name \"Release $CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\" --tag-name \"release-$CI_COMMIT_SHA\" --ref \"$CI_COMMIT_SHA\""]) end end diff --git a/spec/lib/gitlab/ci/charts_spec.rb b/spec/lib/gitlab/ci/charts_spec.rb index cfb7a3f72fa..e00e5ed3920 100644 --- a/spec/lib/gitlab/ci/charts_spec.rb +++ b/spec/lib/gitlab/ci/charts_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Charts do +RSpec.describe Gitlab::Ci::Charts do context "yearchart" do let(:project) { create(:project) } let(:chart) { Gitlab::Ci::Charts::YearChart.new(project) } diff --git a/spec/lib/gitlab/ci/config/edge_stages_injector_spec.rb b/spec/lib/gitlab/ci/config/edge_stages_injector_spec.rb index 042f9b591b6..52ea925c1c4 100644 --- a/spec/lib/gitlab/ci/config/edge_stages_injector_spec.rb +++ b/spec/lib/gitlab/ci/config/edge_stages_injector_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Config::EdgeStagesInjector do +RSpec.describe Gitlab::Ci::Config::EdgeStagesInjector do describe '#call' do subject { described_class.new(config).to_hash } diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index 8cfd07df777..028dcd3e1e6 100644 --- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Artifacts do +RSpec.describe Gitlab::Ci::Config::Entry::Artifacts do let(:entry) { described_class.new(config) } describe 'validation' do diff --git a/spec/lib/gitlab/ci/config/entry/bridge_spec.rb b/spec/lib/gitlab/ci/config/entry/bridge_spec.rb index d08ce30618d..f33176c3da3 100644 --- a/spec/lib/gitlab/ci/config/entry/bridge_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/bridge_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Bridge do +RSpec.describe Gitlab::Ci::Config::Entry::Bridge do subject { described_class.new(config, name: :my_bridge) } it_behaves_like 'with inheritable CI config' do diff --git a/spec/lib/gitlab/ci/config/entry/cache_spec.rb b/spec/lib/gitlab/ci/config/entry/cache_spec.rb index f7b14360af3..3501812b76e 100644 --- a/spec/lib/gitlab/ci/config/entry/cache_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/cache_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Cache do +RSpec.describe Gitlab::Ci::Config::Entry::Cache do subject(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/commands_spec.rb b/spec/lib/gitlab/ci/config/entry/commands_spec.rb index 8e7f9ab9706..439799fe973 100644 --- a/spec/lib/gitlab/ci/config/entry/commands_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/commands_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Commands do +RSpec.describe Gitlab::Ci::Config::Entry::Commands do let(:entry) { described_class.new(config) } context 'when entry config value is an array of strings' do diff --git a/spec/lib/gitlab/ci/config/entry/coverage_spec.rb b/spec/lib/gitlab/ci/config/entry/coverage_spec.rb index 877e3ec6216..c4353e822ae 100644 --- a/spec/lib/gitlab/ci/config/entry/coverage_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/coverage_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Coverage do +RSpec.describe Gitlab::Ci::Config::Entry::Coverage do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/default_spec.rb b/spec/lib/gitlab/ci/config/entry/default_spec.rb index 23c62bbf92a..6e46d02a96e 100644 --- a/spec/lib/gitlab/ci/config/entry/default_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/default_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Default do +RSpec.describe Gitlab::Ci::Config::Entry::Default do let(:entry) { described_class.new(config) } it_behaves_like 'with inheritable CI config' do diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb index 8c21d5342cc..0c18a7fb71e 100644 --- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Environment do +RSpec.describe Gitlab::Ci::Config::Entry::Environment do let(:entry) { described_class.new(config) } before do @@ -102,6 +102,17 @@ describe Gitlab::Ci::Config::Entry::Environment do end end + context 'when prepare action is used' do + let(:config) do + { name: 'production', + action: 'prepare' } + end + + it 'is valid' do + expect(entry).to be_valid + end + end + context 'when wrong action type is used' do let(:config) do { name: 'production', @@ -137,7 +148,7 @@ describe Gitlab::Ci::Config::Entry::Environment do describe '#errors' do it 'contains error about invalid action' do expect(entry.errors) - .to include 'environment action should be start or stop' + .to include 'environment action should be start, stop or prepare' end end end diff --git a/spec/lib/gitlab/ci/config/entry/files_spec.rb b/spec/lib/gitlab/ci/config/entry/files_spec.rb index 2bebbd7b198..6a101d80c7d 100644 --- a/spec/lib/gitlab/ci/config/entry/files_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/files_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Files do +RSpec.describe Gitlab::Ci::Config::Entry::Files do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/hidden_spec.rb b/spec/lib/gitlab/ci/config/entry/hidden_spec.rb index 40b73352676..090ef67f39d 100644 --- a/spec/lib/gitlab/ci/config/entry/hidden_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/hidden_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Hidden do +RSpec.describe Gitlab::Ci::Config::Entry::Hidden do describe '.matching?' do subject { described_class.matching?(name, {}) } diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index de3e887a6ed..c3d91057328 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Image do +RSpec.describe Gitlab::Ci::Config::Entry::Image do let(:entry) { described_class.new(config) } context 'when configuration is a string' do diff --git a/spec/lib/gitlab/ci/config/entry/include_spec.rb b/spec/lib/gitlab/ci/config/entry/include_spec.rb index bab11f26fa1..3e816f70c03 100644 --- a/spec/lib/gitlab/ci/config/entry/include_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/include_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Config::Entry::Include do +RSpec.describe ::Gitlab::Ci::Config::Entry::Include do subject(:include_entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/inherit/default_spec.rb b/spec/lib/gitlab/ci/config/entry/inherit/default_spec.rb index 073f93ce542..7cd9b0acb99 100644 --- a/spec/lib/gitlab/ci/config/entry/inherit/default_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/inherit/default_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Config::Entry::Inherit::Default do +RSpec.describe ::Gitlab::Ci::Config::Entry::Inherit::Default do using RSpec::Parameterized::TableSyntax subject { described_class.new(config) } diff --git a/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb index 06deed11c15..b1a8fbcdbe0 100644 --- a/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Config::Entry::Inherit::Variables do +RSpec.describe ::Gitlab::Ci::Config::Entry::Inherit::Variables do using RSpec::Parameterized::TableSyntax subject { described_class.new(config) } diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index b6279485426..180c52ee1ab 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Job do +RSpec.describe Gitlab::Ci::Config::Entry::Job do let(:entry) { described_class.new(config, name: :rspec) } it_behaves_like 'with inheritable CI config' do @@ -33,7 +33,7 @@ describe Gitlab::Ci::Config::Entry::Job do inherit] end - it { is_expected.to match_array result } + it { is_expected.to include(*result) } end end diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb index 203342ab620..8561bd330b7 100644 --- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Jobs do +RSpec.describe Gitlab::Ci::Config::Entry::Jobs do let(:entry) { described_class.new(config) } let(:config) do diff --git a/spec/lib/gitlab/ci/config/entry/key_spec.rb b/spec/lib/gitlab/ci/config/entry/key_spec.rb index 327607e2266..4ee1ffb29ad 100644 --- a/spec/lib/gitlab/ci/config/entry/key_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/key_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Key do +RSpec.describe Gitlab::Ci::Config::Entry::Key do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb index 468e83ec506..53809d2d549 100644 --- a/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Kubernetes do +RSpec.describe Gitlab::Ci::Config::Entry::Kubernetes do subject { described_class.new(config) } describe 'attributes' do diff --git a/spec/lib/gitlab/ci/config/entry/need_spec.rb b/spec/lib/gitlab/ci/config/entry/need_spec.rb index 92b71c5f6cc..5a826bf8282 100644 --- a/spec/lib/gitlab/ci/config/entry/need_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/need_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Config::Entry::Need do +RSpec.describe ::Gitlab::Ci::Config::Entry::Need do subject(:need) { described_class.new(config) } shared_examples 'job type' do diff --git a/spec/lib/gitlab/ci/config/entry/needs_spec.rb b/spec/lib/gitlab/ci/config/entry/needs_spec.rb index b8b84b5efd2..f3b9d0c3c84 100644 --- a/spec/lib/gitlab/ci/config/entry/needs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/needs_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Config::Entry::Needs do +RSpec.describe ::Gitlab::Ci::Config::Entry::Needs do subject(:needs) { described_class.new(config) } before do diff --git a/spec/lib/gitlab/ci/config/entry/paths_spec.rb b/spec/lib/gitlab/ci/config/entry/paths_spec.rb index 221d5ae5863..dd4e7befc46 100644 --- a/spec/lib/gitlab/ci/config/entry/paths_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/paths_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Paths do +RSpec.describe Gitlab::Ci::Config::Entry::Paths do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/policy_spec.rb b/spec/lib/gitlab/ci/config/entry/policy_spec.rb index a606eb303e7..46800055dd9 100644 --- a/spec/lib/gitlab/ci/config/entry/policy_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/policy_spec.rb @@ -4,7 +4,7 @@ require 'fast_spec_helper' require 'support/helpers/stub_feature_flags' require_dependency 'active_model' -describe Gitlab::Ci::Config::Entry::Policy do +RSpec.describe Gitlab::Ci::Config::Entry::Policy do let(:entry) { described_class.new(config) } context 'when using simplified policy' do diff --git a/spec/lib/gitlab/ci/config/entry/port_spec.rb b/spec/lib/gitlab/ci/config/entry/port_spec.rb index 5f8f294334e..e2840c07f6b 100644 --- a/spec/lib/gitlab/ci/config/entry/port_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/port_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Port do +RSpec.describe Gitlab::Ci::Config::Entry::Port do let(:entry) { described_class.new(config) } before do diff --git a/spec/lib/gitlab/ci/config/entry/ports_spec.rb b/spec/lib/gitlab/ci/config/entry/ports_spec.rb index 2063bd1d86c..f738c4ee875 100644 --- a/spec/lib/gitlab/ci/config/entry/ports_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/ports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Ports do +RSpec.describe Gitlab::Ci::Config::Entry::Ports do let(:entry) { described_class.new(config) } before do diff --git a/spec/lib/gitlab/ci/config/entry/prefix_spec.rb b/spec/lib/gitlab/ci/config/entry/prefix_spec.rb index 8132a674488..b337747f5d6 100644 --- a/spec/lib/gitlab/ci/config/entry/prefix_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/prefix_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Prefix do +RSpec.describe Gitlab::Ci::Config::Entry::Prefix do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/processable_spec.rb b/spec/lib/gitlab/ci/config/entry/processable_spec.rb index 8447a29c772..fdf6008f89f 100644 --- a/spec/lib/gitlab/ci/config/entry/processable_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/processable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Processable do +RSpec.describe Gitlab::Ci::Config::Entry::Processable do let(:node_class) do Class.new(::Gitlab::Config::Entry::Node) do include Gitlab::Ci::Config::Entry::Processable @@ -231,6 +231,12 @@ describe Gitlab::Ci::Config::Entry::Processable do end context 'when workflow rules is used' do + let(:workflow) { double('workflow', 'has_rules?' => true) } + + before do + entry.compose!(deps) + end + context 'when rules are used' do let(:config) { { script: 'ls', cache: { key: 'test' }, rules: [] } } @@ -239,11 +245,11 @@ describe Gitlab::Ci::Config::Entry::Processable do end end - context 'when rules are not used' do + context 'when rules are not used and only is defined' do let(:config) { { script: 'ls', cache: { key: 'test' }, only: [] } } - it 'does not define only' do - expect(entry).not_to be_only_defined + it 'keeps only entry' do + expect(entry).to be_only_defined end end end diff --git a/spec/lib/gitlab/ci/config/entry/release/assets/link_spec.rb b/spec/lib/gitlab/ci/config/entry/release/assets/link_spec.rb index 0e346de3d9e..bc320258412 100644 --- a/spec/lib/gitlab/ci/config/entry/release/assets/link_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/release/assets/link_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Release::Assets::Link do +RSpec.describe Gitlab::Ci::Config::Entry::Release::Assets::Link do let(:entry) { described_class.new(config) } describe 'validation' do diff --git a/spec/lib/gitlab/ci/config/entry/release/assets/links_spec.rb b/spec/lib/gitlab/ci/config/entry/release/assets/links_spec.rb index d12e8d966ab..440745d9eb3 100644 --- a/spec/lib/gitlab/ci/config/entry/release/assets/links_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/release/assets/links_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Release::Assets::Links do +RSpec.describe Gitlab::Ci::Config::Entry::Release::Assets::Links do let(:entry) { described_class.new(config) } describe 'validation' do diff --git a/spec/lib/gitlab/ci/config/entry/release/assets_spec.rb b/spec/lib/gitlab/ci/config/entry/release/assets_spec.rb index 08ad5764eaa..3d44d7d9903 100644 --- a/spec/lib/gitlab/ci/config/entry/release/assets_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/release/assets_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Release::Assets do +RSpec.describe Gitlab::Ci::Config::Entry::Release::Assets do let(:entry) { described_class.new(config) } describe 'validation' do diff --git a/spec/lib/gitlab/ci/config/entry/release_spec.rb b/spec/lib/gitlab/ci/config/entry/release_spec.rb index 500897569e9..e5155f91be4 100644 --- a/spec/lib/gitlab/ci/config/entry/release_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/release_spec.rb @@ -2,24 +2,35 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Release do +RSpec.describe Gitlab::Ci::Config::Entry::Release do let(:entry) { described_class.new(config) } + shared_examples_for 'a valid entry' do + describe '#value' do + it 'returns release configuration' do + expect(entry.value).to eq config + end + end + + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid + end + end + end + + shared_examples_for 'reports error' do |message| + it 'reports error' do + expect(entry.errors) + .to include message + end + end + describe 'validation' do context 'when entry config value is correct' do let(:config) { { tag_name: 'v0.06', description: "./release_changelog.txt" } } - describe '#value' do - it 'returns release configuration' do - expect(entry.value).to eq config - end - end - - describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid - end - end + it_behaves_like 'a valid entry' end context "when value includes 'assets' keyword" do @@ -36,38 +47,144 @@ describe Gitlab::Ci::Config::Entry::Release do } end - describe '#value' do - it 'returns release configuration' do - expect(entry.value).to eq config - end + it_behaves_like 'a valid entry' + end + + context "when value includes 'name' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME" + } end - describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid - end + it_behaves_like 'a valid entry' + end + + context "when value includes 'ref' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME", + ref: 'b3235930aa443112e639f941c69c578912189bdd' + } end + + it_behaves_like 'a valid entry' end - context "when value includes 'name' keyword" do + context "when value includes 'released_at' keyword" do let(:config) do { tag_name: 'v0.06', description: "./release_changelog.txt", - name: "Release $CI_TAG_NAME" + name: "Release $CI_TAG_NAME", + released_at: '2019-03-15T08:00:00Z' } end - describe '#value' do - it 'returns release configuration' do - expect(entry.value).to eq config - end + it_behaves_like 'a valid entry' + end + + context "when value includes 'milestones' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME", + milestones: milestones + } end - describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid - end + context 'for an array of milestones' do + let(:milestones) { %w[m1 m2 m3] } + + it_behaves_like 'a valid entry' + end + + context 'for a single milestone' do + let(:milestones) { 'm1' } + + it_behaves_like 'a valid entry' + end + end + + context "when value includes 'ref' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME", + ref: ref + } + end + + context "when 'ref' is a full commit SHA" do + let(:ref) { 'b3235930aa443112e639f941c69c578912189bdd' } + + it_behaves_like 'a valid entry' + end + + context "when 'ref' is a short commit SHA" do + let(:ref) { 'b3235930'} + + it_behaves_like 'a valid entry' + end + + context "when 'ref' is a branch name" do + let(:ref) { 'fix/123-branch-name'} + + it_behaves_like 'a valid entry' + end + + context "when 'ref' is a semantic versioning tag" do + let(:ref) { 'v1.2.3'} + + it_behaves_like 'a valid entry' + end + + context "when 'ref' is a semantic versioning tag rc" do + let(:ref) { 'v1.2.3-rc'} + + it_behaves_like 'a valid entry' + end + end + + context "when value includes 'released_at' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME", + released_at: '2019-03-15T08:00:00Z' + } + end + + it_behaves_like 'a valid entry' + end + + context "when value includes 'milestones' keyword" do + let(:config) do + { + tag_name: 'v0.06', + description: "./release_changelog.txt", + name: "Release $CI_TAG_NAME", + milestones: milestones + } + end + + context 'for an array of milestones' do + let(:milestones) { %w[m1 m2 m3] } + + it_behaves_like 'a valid entry' + end + + context 'for a single milestone' do + let(:milestones) { 'm1' } + + it_behaves_like 'a valid entry' end end @@ -76,37 +193,43 @@ describe Gitlab::Ci::Config::Entry::Release do context 'when value of attribute is invalid' do let(:config) { { description: 10 } } - it 'reports error' do - expect(entry.errors) - .to include 'release description should be a string' - end + it_behaves_like 'reports error', 'release description should be a string' end context 'when release description is missing' do let(:config) { { tag_name: 'v0.06' } } - it 'reports error' do - expect(entry.errors) - .to include "release description can't be blank" - end + it_behaves_like 'reports error', "release description can't be blank" end context 'when release tag_name is missing' do let(:config) { { description: "./release_changelog.txt" } } - it 'reports error' do - expect(entry.errors) - .to include "release tag name can't be blank" - end + it_behaves_like 'reports error', "release tag name can't be blank" end context 'when there is an unknown key present' do let(:config) { { test: 100 } } - it 'reports error' do - expect(entry.errors) - .to include 'release config contains unknown keys: test' - end + it_behaves_like 'reports error', 'release config contains unknown keys: test' + end + + context 'when `released_at` is not a valid date' do + let(:config) { { released_at: 'ABC123' } } + + it_behaves_like 'reports error', 'release released at must be a valid datetime' + end + + context 'when `ref` is not valid' do + let(:config) { { ref: 'invalid\branch' } } + + it_behaves_like 'reports error', 'release ref must be a valid ref' + end + + context 'when `milestones` is not an array of strings' do + let(:config) { { milestones: [1, 2, 3] } } + + it_behaves_like 'reports error', 'release milestones should be an array of strings or a string' end end end diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb index 2c12a88dedb..98105ebcd55 100644 --- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Reports do +RSpec.describe Gitlab::Ci::Config::Entry::Reports do let(:entry) { described_class.new(config) } describe 'validates ALLOWED_KEYS' do @@ -44,6 +44,9 @@ describe Gitlab::Ci::Config::Entry::Reports do :license_management | 'gl-license-management-report.json' :license_scanning | 'gl-license-scanning-report.json' :performance | 'performance.json' + :browser_performance | 'browser-performance.json' + :browser_performance | 'performance.json' + :load_performance | 'load-performance.json' :lsif | 'lsif.json' :dotenv | 'build.dotenv' :cobertura | 'cobertura-coverage.xml' diff --git a/spec/lib/gitlab/ci/config/entry/retry_spec.rb b/spec/lib/gitlab/ci/config/entry/retry_spec.rb index 67253c71f6b..b38387a437e 100644 --- a/spec/lib/gitlab/ci/config/entry/retry_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/retry_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Retry do +RSpec.describe Gitlab::Ci::Config::Entry::Retry do let(:entry) { described_class.new(config) } shared_context 'when retry value is a numeric', :numeric do diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb index ba2dbf72fba..140b3c4f55b 100644 --- a/spec/lib/gitlab/ci/config/entry/root_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Root do +RSpec.describe Gitlab::Ci::Config::Entry::Root do let(:root) { described_class.new(hash) } describe '.nodes' do diff --git a/spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb b/spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb index 20db5f02fc7..4a43e6c9a86 100644 --- a/spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb @@ -5,7 +5,7 @@ require 'gitlab_chronic_duration' require 'support/helpers/stub_feature_flags' require_dependency 'active_model' -describe Gitlab::Ci::Config::Entry::Rules::Rule do +RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule do let(:factory) do Gitlab::Config::Entry::Factory.new(described_class) .metadata(metadata) diff --git a/spec/lib/gitlab/ci/config/entry/rules_spec.rb b/spec/lib/gitlab/ci/config/entry/rules_spec.rb index 3c050801023..7d26365e7b3 100644 --- a/spec/lib/gitlab/ci/config/entry/rules_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/rules_spec.rb @@ -4,7 +4,7 @@ require 'fast_spec_helper' require 'support/helpers/stub_feature_flags' require_dependency 'active_model' -describe Gitlab::Ci::Config::Entry::Rules do +RSpec.describe Gitlab::Ci::Config::Entry::Rules do let(:factory) do Gitlab::Config::Entry::Factory.new(described_class) .metadata(metadata) diff --git a/spec/lib/gitlab/ci/config/entry/script_spec.rb b/spec/lib/gitlab/ci/config/entry/script_spec.rb index 57dc20ea628..1ddf7881e81 100644 --- a/spec/lib/gitlab/ci/config/entry/script_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/script_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Script do +RSpec.describe Gitlab::Ci::Config::Entry::Script do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 66cca100688..9fbc14c19b9 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Service do +RSpec.describe Gitlab::Ci::Config::Entry::Service do let(:entry) { described_class.new(config) } before do diff --git a/spec/lib/gitlab/ci/config/entry/services_spec.rb b/spec/lib/gitlab/ci/config/entry/services_spec.rb index 764f783b083..e4f8a348d21 100644 --- a/spec/lib/gitlab/ci/config/entry/services_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/services_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Services do +RSpec.describe Gitlab::Ci::Config::Entry::Services do let(:entry) { described_class.new(config) } before do diff --git a/spec/lib/gitlab/ci/config/entry/stage_spec.rb b/spec/lib/gitlab/ci/config/entry/stage_spec.rb index 574fa00575a..2a105fb978e 100644 --- a/spec/lib/gitlab/ci/config/entry/stage_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/stage_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Stage do +RSpec.describe Gitlab::Ci::Config::Entry::Stage do let(:stage) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/stages_spec.rb b/spec/lib/gitlab/ci/config/entry/stages_spec.rb index 3e6ff8eca28..1dd11bb03f8 100644 --- a/spec/lib/gitlab/ci/config/entry/stages_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/stages_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Stages do +RSpec.describe Gitlab::Ci::Config::Entry::Stages do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb index dfd9807583c..5b4289741f3 100644 --- a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Trigger do +RSpec.describe Gitlab::Ci::Config::Entry::Trigger do subject { described_class.new(config) } context 'when trigger config is a non-empty string' do diff --git a/spec/lib/gitlab/ci/config/entry/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/variables_spec.rb index 1320b366367..d6391092f63 100644 --- a/spec/lib/gitlab/ci/config/entry/variables_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/variables_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Variables do +RSpec.describe Gitlab::Ci::Config::Entry::Variables do let(:entry) { described_class.new(config) } describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/workflow_spec.rb b/spec/lib/gitlab/ci/config/entry/workflow_spec.rb index f2832b94bf0..3d19832e13d 100644 --- a/spec/lib/gitlab/ci/config/entry/workflow_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/workflow_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::Entry::Workflow do +RSpec.describe Gitlab::Ci::Config::Entry::Workflow do let(:factory) { Gitlab::Config::Entry::Factory.new(described_class).value(rules_hash) } let(:config) { factory.create! } diff --git a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb index e00104e3c68..69aa3bab77a 100644 --- a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Config::Extendable::Entry do +RSpec.describe Gitlab::Ci::Config::Extendable::Entry do describe '.new' do context 'when entry key is not included in the context hash' do it 'raises error' do diff --git a/spec/lib/gitlab/ci/config/extendable_spec.rb b/spec/lib/gitlab/ci/config/extendable_spec.rb index 874b224067b..481f55d790e 100644 --- a/spec/lib/gitlab/ci/config/extendable_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Config::Extendable do +RSpec.describe Gitlab::Ci::Config::Extendable do subject { described_class.new(hash) } describe '#each' do diff --git a/spec/lib/gitlab/ci/config/external/context_spec.rb b/spec/lib/gitlab/ci/config/external/context_spec.rb index 610646ca85a..4b9adf7e87b 100644 --- a/spec/lib/gitlab/ci/config/external/context_spec.rb +++ b/spec/lib/gitlab/ci/config/external/context_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Config::External::Context do +RSpec.describe Gitlab::Ci::Config::External::Context do let(:project) { double('Project') } let(:user) { double('User') } let(:sha) { '12345' } diff --git a/spec/lib/gitlab/ci/config/external/file/artifact_spec.rb b/spec/lib/gitlab/ci/config/external/file/artifact_spec.rb index a8eb13c47bc..8dd92c5b5fd 100644 --- a/spec/lib/gitlab/ci/config/external/file/artifact_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/artifact_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Artifact do +RSpec.describe Gitlab::Ci::Config::External::File::Artifact do let(:parent_pipeline) { create(:ci_pipeline) } let(:context) do Gitlab::Ci::Config::External::Context.new(parent_pipeline: parent_pipeline) diff --git a/spec/lib/gitlab/ci/config/external/file/base_spec.rb b/spec/lib/gitlab/ci/config/external/file/base_spec.rb index d472d6527e2..445edb253fd 100644 --- a/spec/lib/gitlab/ci/config/external/file/base_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/base_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Base do +RSpec.describe Gitlab::Ci::Config::External::File::Base do let(:context_params) { { sha: 'HEAD' } } let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) } diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb index c9851239859..993a07568de 100644 --- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Local do +RSpec.describe Gitlab::Ci::Config::External::File::Local do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } let(:sha) { '12345' } diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb index 4d8f0dbc861..a5e4e27df6f 100644 --- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Project do +RSpec.describe Gitlab::Ci::Config::External::File::Project do let_it_be(:context_project) { create(:project) } let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb index a23cce9b757..ab60ac215ba 100644 --- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Remote do +RSpec.describe Gitlab::Ci::Config::External::File::Remote do include StubRequests let(:context_params) { { sha: '12345' } } diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb index 7ea5aadac52..ad1d93a64a1 100644 --- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::File::Template do +RSpec.describe Gitlab::Ci::Config::External::File::Template do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } let(:context_params) { { project: project, sha: '12345', user: user } } diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb index fa358f36527..bf14d8d6b34 100644 --- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb +++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::Mapper do +RSpec.describe Gitlab::Ci::Config::External::Mapper do include StubRequests let_it_be(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb index 45f646660a7..b2cf36b2597 100644 --- a/spec/lib/gitlab/ci/config/external/processor_spec.rb +++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config::External::Processor do +RSpec.describe Gitlab::Ci::Config::External::Processor do include StubRequests let_it_be(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/ci/config/normalizer_spec.rb b/spec/lib/gitlab/ci/config/normalizer_spec.rb index db62fb7524d..d3d165ba00f 100644 --- a/spec/lib/gitlab/ci/config/normalizer_spec.rb +++ b/spec/lib/gitlab/ci/config/normalizer_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Config::Normalizer do +RSpec.describe Gitlab::Ci::Config::Normalizer do let(:job_name) { :rspec } let(:job_config) { { script: 'rspec', parallel: 5, name: 'rspec' } } let(:config) { { job_name => job_config } } diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb index 3b65dbe11ec..18be9558829 100644 --- a/spec/lib/gitlab/ci/config_spec.rb +++ b/spec/lib/gitlab/ci/config_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Config do +RSpec.describe Gitlab::Ci::Config do include StubRequests let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/ci/cron_parser_spec.rb b/spec/lib/gitlab/ci/cron_parser_spec.rb index 8f9f3d7fa37..f724825a9cc 100644 --- a/spec/lib/gitlab/ci/cron_parser_spec.rb +++ b/spec/lib/gitlab/ci/cron_parser_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::CronParser do +RSpec.describe Gitlab::Ci::CronParser do shared_examples_for "returns time in the future" do it { is_expected.to be > Time.now } end diff --git a/spec/lib/gitlab/ci/jwt_spec.rb b/spec/lib/gitlab/ci/jwt_spec.rb index f2897708b08..a15f3310dab 100644 --- a/spec/lib/gitlab/ci/jwt_spec.rb +++ b/spec/lib/gitlab/ci/jwt_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Jwt do +RSpec.describe Gitlab::Ci::Jwt do let(:namespace) { build_stubbed(:namespace) } let(:project) { build_stubbed(:project, namespace: namespace) } let(:user) { build_stubbed(:user) } diff --git a/spec/lib/gitlab/ci/mask_secret_spec.rb b/spec/lib/gitlab/ci/mask_secret_spec.rb index 6607aaae399..7b2d6b58518 100644 --- a/spec/lib/gitlab/ci/mask_secret_spec.rb +++ b/spec/lib/gitlab/ci/mask_secret_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::MaskSecret do +RSpec.describe Gitlab::Ci::MaskSecret do subject { described_class } describe '#mask' do diff --git a/spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb b/spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb index 4d87e3b201a..b3edf452f36 100644 --- a/spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb +++ b/spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'spec_helper' -describe Gitlab::Ci::Parsers::Accessibility::Pa11y do +RSpec.describe Gitlab::Ci::Parsers::Accessibility::Pa11y do describe '#parse!' do subject { described_class.new.parse!(pa11y, accessibility_report) } @@ -108,7 +108,7 @@ describe Gitlab::Ci::Parsers::Accessibility::Pa11y do it "sets error_message" do expect { subject }.not_to raise_error - expect(accessibility_report.error_message).to include('Pa11y parsing failed') + expect(accessibility_report.error_message).to include('JSON parsing failed') expect(accessibility_report.errors_count).to eq(0) expect(accessibility_report.passes_count).to eq(0) expect(accessibility_report.scans_count).to eq(0) diff --git a/spec/lib/gitlab/ci/parsers/coverage/cobertura_spec.rb b/spec/lib/gitlab/ci/parsers/coverage/cobertura_spec.rb index e97544683db..08a3fbd7867 100644 --- a/spec/lib/gitlab/ci/parsers/coverage/cobertura_spec.rb +++ b/spec/lib/gitlab/ci/parsers/coverage/cobertura_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Parsers::Coverage::Cobertura do +RSpec.describe Gitlab::Ci::Parsers::Coverage::Cobertura do describe '#parse!' do subject { described_class.new.parse!(cobertura, coverage_report) } diff --git a/spec/lib/gitlab/ci/parsers/terraform/tfplan_spec.rb b/spec/lib/gitlab/ci/parsers/terraform/tfplan_spec.rb index fec27c0f31a..f487fccdab7 100644 --- a/spec/lib/gitlab/ci/parsers/terraform/tfplan_spec.rb +++ b/spec/lib/gitlab/ci/parsers/terraform/tfplan_spec.rb @@ -2,39 +2,86 @@ require 'spec_helper' -describe Gitlab::Ci::Parsers::Terraform::Tfplan do +RSpec.describe Gitlab::Ci::Parsers::Terraform::Tfplan do describe '#parse!' do - let_it_be(:artifact) { create(:ci_job_artifact, :terraform) } + let(:artifact) { create(:ci_job_artifact, :terraform) } let(:reports) { Gitlab::Ci::Reports::TerraformReports.new } context 'when data is invalid' do - context 'when there is no data' do - it 'raises an error' do - plan = '{}' + context 'when data is not a JSON file' do + it 'reports an invalid_json_format error' do + plan = 'Not a JSON file' + + expect { subject.parse!(plan, reports, artifact: artifact) }.not_to raise_error + + reports.plans.each do |key, hash_value| + expect(hash_value.keys).to match_array(%w[job_id job_name job_path tf_report_error]) + end - expect { subject.parse!(plan, reports, artifact: artifact) }.to raise_error( - described_class::TfplanParserError + expect(reports.plans).to match( + a_hash_including( + artifact.job.id.to_s => a_hash_including( + 'tf_report_error' => :invalid_json_format + ) + ) ) end end - context 'when data is not a JSON file' do - it 'raises an error' do - plan = { 'create' => 0, 'update' => 1, 'delete' => 0 }.to_s + context 'when JSON is missing a required key' do + it 'reports an invalid_json_keys error' do + plan = '{ "wrong_key": 1 }' + + expect { subject.parse!(plan, reports, artifact: artifact) }.not_to raise_error + + reports.plans.each do |key, hash_value| + expect(hash_value.keys).to match_array(%w[job_id job_name job_path tf_report_error]) + end - expect { subject.parse!(plan, reports, artifact: artifact) }.to raise_error( - described_class::TfplanParserError + expect(reports.plans).to match( + a_hash_including( + artifact.job.id.to_s => a_hash_including( + 'tf_report_error' => :missing_json_keys + ) + ) ) end end - context 'when JSON is missing a required key' do - it 'raises an error' do - plan = '{ "wrong_key": 1 }' + context 'when artifact is invalid' do + it 'reports an :unknown_error' do + expect { subject.parse!('{}', reports, artifact: nil) }.not_to raise_error + + reports.plans.each do |key, hash_value| + expect(hash_value.keys).to match_array(%w[tf_report_error]) + end + + expect(reports.plans).to match( + a_hash_including( + 'failed_tf_plan' => a_hash_including( + 'tf_report_error' => :unknown_error + ) + ) + ) + end + end + + context 'when job is invalid' do + it 'reports an :unknown_error' do + artifact.job_id = nil + expect { subject.parse!('{}', reports, artifact: artifact) }.not_to raise_error - expect { subject.parse!(plan, reports, artifact: artifact) }.to raise_error( - described_class::TfplanParserError + reports.plans.each do |key, hash_value| + expect(hash_value.keys).to match_array(%w[tf_report_error]) + end + + expect(reports.plans).to match( + a_hash_including( + 'failed_tf_plan' => a_hash_including( + 'tf_report_error' => :unknown_error + ) + ) ) end end @@ -47,7 +94,7 @@ describe Gitlab::Ci::Parsers::Terraform::Tfplan do expect { subject.parse!(plan, reports, artifact: artifact) }.not_to raise_error reports.plans.each do |key, hash_value| - expect(hash_value.keys).to match_array(%w[create delete job_name job_path update]) + expect(hash_value.keys).to match_array(%w[create delete job_id job_name job_path update]) end expect(reports.plans).to match( @@ -68,7 +115,7 @@ describe Gitlab::Ci::Parsers::Terraform::Tfplan do expect { subject.parse!(plan, reports, artifact: artifact) }.not_to raise_error reports.plans.each do |key, hash_value| - expect(hash_value.keys).to match_array(%w[create delete job_name job_path update]) + expect(hash_value.keys).to match_array(%w[create delete job_id job_name job_path update]) end expect(reports.plans).to match( diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb index 7b7ace02bba..1f497dea2bf 100644 --- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb +++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Parsers::Test::Junit do +RSpec.describe Gitlab::Ci::Parsers::Test::Junit do describe '#parse!' do subject { described_class.new.parse!(junit, test_suite, args) } diff --git a/spec/lib/gitlab/ci/parsers_spec.rb b/spec/lib/gitlab/ci/parsers_spec.rb index 0a266e7a206..db9a5775d9f 100644 --- a/spec/lib/gitlab/ci/parsers_spec.rb +++ b/spec/lib/gitlab/ci/parsers_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Parsers do +RSpec.describe Gitlab::Ci::Parsers do describe '.fabricate!' do subject { described_class.fabricate!(file_type) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb index 542a2462b59..5fa414f5bd1 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Build::Associations do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Build::Associations do let(:project) { create(:project, :repository) } let(:user) { create(:user, developer_projects: [project]) } let(:pipeline) { Ci::Pipeline.new } diff --git a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb index 094563bd979..6da565a2bf6 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Build do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Build do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user, developer_projects: [project]) } let(:pipeline) { Ci::Pipeline.new } diff --git a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb index 56707f4e6e4..bc2012e83bd 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Command do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Command do let_it_be(:project) { create(:project, :repository) } describe '#initialize' do @@ -270,4 +270,29 @@ describe Gitlab::Ci::Pipeline::Chain::Command do it { is_expected. to eq(true) } end end + + describe '#dangling_build?' do + let(:project) { create(:project, :repository) } + let(:command) { described_class.new(project: project, source: source) } + + subject { command.dangling_build? } + + context 'when source is :webide' do + let(:source) { :webide } + + it { is_expected.to eq(true) } + end + + context 'when source is :ondemand_dast_scan' do + let(:source) { :ondemand_dast_scan } + + it { is_expected.to eq(true) } + end + + context 'when source something else' do + let(:source) { :web } + + it { is_expected.to eq(false) } + end + end end diff --git a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb index fc95bb602c2..42ec9ab6f5d 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb @@ -2,10 +2,12 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Config::Content do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Config::Content do let(:project) { create(:project, ci_config_path: ci_config_path) } let(:pipeline) { build(:ci_pipeline, project: project) } - let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new(project: project) } + let(:content) { nil } + let(:source) { :push } + let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new(project: project, content: content, source: source) } subject { described_class.new(pipeline, command) } @@ -141,6 +143,26 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do end end + context 'when config is passed as a parameter' do + let(:source) { :ondemand_dast_scan } + let(:ci_config_path) { nil } + let(:content) do + <<~EOY + --- + stages: + - dast + EOY + end + + it 'uses the parameter content' do + subject.perform! + + expect(pipeline.config_source).to eq 'parameter_source' + expect(pipeline.pipeline_config.content).to eq(content) + expect(command.config_content).to eq(content) + end + end + context 'when config is not defined anywhere' do let(:ci_config_path) { nil } diff --git a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb index f18ad05a704..d60ecc80a6e 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Create do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Create do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb index 7b76adaf683..4ae51ac8bf9 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules do +RSpec.describe Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules do let(:project) { create(:project) } let(:user) { create(:user) } let(:pipeline) { build(:ci_pipeline, project: project) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb index 6dab5679e60..8c02121857a 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Populate do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } 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 92eadf5548c..8b9de16ce5f 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 @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do +RSpec.describe ::Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do let(:project) { create(:project) } let(:pipeline) do diff --git a/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb index 1e1d5c2a724..f83cd49d780 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Seed do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Seed do let(:project) { create(:project, :repository) } let(:user) { create(:user, developer_projects: [project]) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb index ea04862ed74..5d20b1b8fda 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Sequence do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb index 55d6d35340e..e4768f2ef0d 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Skip do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Skip do let_it_be(:project, reload: true) { create(:project) } let_it_be(:user) { create(:user) } let_it_be(:pipeline, reload: true) { create(:ci_pipeline, project: project) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb index 8bf8bdf08ff..ae3270cb9b2 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do let_it_be(:project, reload: true) { create(:project, :repository) } let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index 9a2cf014007..931c62701ce 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Validate::External do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do let(:project) { create(:project) } let(:user) { create(:user) } let(:pipeline) { build(:ci_empty_pipeline, user: user, project: project) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb index 83271007ab0..1dc2e0a1822 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } let(:pipeline) { build_stubbed(:ci_pipeline) } diff --git a/spec/lib/gitlab/ci/pipeline/duration_spec.rb b/spec/lib/gitlab/ci/pipeline/duration_spec.rb index a4984092f35..e0b4928d7f7 100644 --- a/spec/lib/gitlab/ci/pipeline/duration_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/duration_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Duration do +RSpec.describe Gitlab::Ci::Pipeline::Duration do let(:calculated_duration) { calculate(data) } shared_examples 'calculating duration' do diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/and_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/and_spec.rb index 847d613dba3..6601537a2d3 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/and_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/and_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' require 'rspec-parameterized' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::And do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::And do let(:left) { double('left', evaluate: nil) } let(:right) { double('right', evaluate: nil) } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb index 0e13681a4cf..2bed47f0a87 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Equals do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Equals do let(:left) { double('left') } let(:right) { double('right') } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb index a527783ffac..efcea0b0e09 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' require_dependency 're2' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do let(:left) { double('left') } let(:right) { double('right') } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_equals_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_equals_spec.rb index a3a48f83b27..a81e1713ef0 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_equals_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_equals_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::NotEquals do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::NotEquals do let(:left) { double('left') } let(:right) { double('right') } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_matches_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_matches_spec.rb index fb4238ecaf3..f44fe19f86d 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_matches_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/not_matches_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' require_dependency 're2' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::NotMatches do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::NotMatches do let(:left) { double('left') } let(:right) { double('right') } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb index 7013c6bacbb..49686d1a9bd 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Null do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Null do describe '.build' do it 'creates a new instance of the token' do expect(described_class.build('null')) diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/or_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/or_spec.rb index 15505ebc82b..7fe445975eb 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/or_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/or_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' require 'rspec-parameterized' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Or do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Or do let(:left) { double('left', evaluate: nil) } let(:right) { double('right', evaluate: nil) } diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb index 2cc25a07417..1a56a91c471 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do describe '.build' do it 'creates a new instance of the token' do expect(described_class.build('/.*/')) diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb index 2a6b90d127f..c6d0d2534a5 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do describe '.build' do it 'creates a new instance of the token' do expect(described_class.build('"my string"')) diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb index 29e26930249..115674edc48 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexeme::Variable do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Variable do describe '.build' do it 'creates a new instance of the token' do expect(described_class.build('$VARIABLE')) diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb index 2b0cee2d6f2..61c6ced4dac 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Lexer do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexer do let(:token_class) do Gitlab::Ci::Pipeline::Expression::Token end diff --git a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb index 10adfa18af6..1704cabfd2e 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Parser do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do describe '#tree' do context 'when using two operators' do it 'returns a reverse descent parse tree' do diff --git a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb index 79ee4d07e3a..642d6816030 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' require 'rspec-parameterized' -describe Gitlab::Ci::Pipeline::Expression::Statement do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Statement do subject do described_class.new(text, variables) end diff --git a/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb index aa807cecb72..137e38d2ead 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb @@ -2,7 +2,7 @@ require 'fast_spec_helper' -describe Gitlab::Ci::Pipeline::Expression::Token do +RSpec.describe Gitlab::Ci::Pipeline::Expression::Token do let(:value) { '$VARIABLE' } let(:lexeme) { Gitlab::Ci::Pipeline::Expression::Lexeme::Variable } diff --git a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb index 40dfd893465..ae423fa04f9 100644 --- a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Preloader do +RSpec.describe Gitlab::Ci::Pipeline::Preloader do let(:stage) { double(:stage) } let(:commit) { double(:commit) } @@ -28,8 +28,9 @@ describe Gitlab::Ci::Pipeline::Preloader do end end - it 'preloads commit authors and number of warnings' do + it 'preloads commit authors, number of warnings and ref commits' do expect(commit).to receive(:lazy_author) + expect(pipeline).to receive(:lazy_ref_commit) expect(pipeline).to receive(:number_of_warnings) expect(stage).to receive(:number_of_warnings) @@ -38,6 +39,7 @@ describe Gitlab::Ci::Pipeline::Preloader do it 'returns original collection' do allow(commit).to receive(:lazy_author) + allow(pipeline).to receive(:lazy_ref_commit) allow(pipeline).to receive(:number_of_warnings) allow(stage).to receive(:number_of_warnings) diff --git a/spec/lib/gitlab/ci/pipeline/seed/build/cache_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build/cache_spec.rb index f5b43b5aeab..74c014b6408 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build/cache_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build/cache_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Build::Cache do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Build::Cache do let_it_be(:project) { create(:project, :repository) } let_it_be(:head_sha) { project.repository.head_commit.id } let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: head_sha) } @@ -134,7 +134,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build::Cache do it_behaves_like 'foo/bar directory key' end - context 'with directories ending in slash star', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/222356' do + context 'with directories ending in slash star' do let(:files) { ['foo/bar/*'] } it_behaves_like 'foo/bar directory key' diff --git a/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb index bf6985156d3..8fcc242ba5f 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Build::ResourceGroup do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Build::ResourceGroup do let_it_be(:project) { create(:project) } let(:job) { build(:ci_build, project: project) } let(:seed) { described_class.new(job, resource_group_key) } diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index 01f65939da7..2dea554fe56 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Build do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do let(:project) { create(:project, :repository) } let(:head_sha) { project.repository.head_commit.id } let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: head_sha) } diff --git a/spec/lib/gitlab/ci/pipeline/seed/deployment_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/deployment_spec.rb index ceb3cb28bc9..1f38c7aec63 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/deployment_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/deployment_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Deployment do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Deployment do let_it_be(:project, refind: true) { create(:project, :repository) } let(:pipeline) do create(:ci_pipeline, project: project, @@ -102,6 +102,19 @@ describe Gitlab::Ci::Pipeline::Seed::Deployment do end end + context 'when job has environment attribute with prepare action' do + let(:attributes) do + { + environment: 'production', + options: { environment: { name: 'production', action: 'prepare' } } + } + end + + it 'returns nothing' do + is_expected.to be_nil + end + end + context 'when job does not have environment attribute' do let(:attributes) { { name: 'test' } } diff --git a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb index 4c0464e5e7c..0c8a0de2f34 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Environment do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Environment do let_it_be(:project) { create(:project) } let(:job) { build(:ci_build, project: project) } let(:seed) { described_class.new(job) } diff --git a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb index 875fd457bd0..4b9db9fa6c6 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Pipeline::Seed::Stage do +RSpec.describe Gitlab::Ci::Pipeline::Seed::Stage do let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:previous_stages) { [] } diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb index 31a330f46b1..240ede790e0 100644 --- a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::AccessibilityReportsComparer do +RSpec.describe Gitlab::Ci::Reports::AccessibilityReportsComparer do let(:comparer) { described_class.new(base_reports, head_reports) } let(:base_reports) { Gitlab::Ci::Reports::AccessibilityReports.new } let(:head_reports) { Gitlab::Ci::Reports::AccessibilityReports.new } diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb index 0dc13b464b1..8c35b2a34cf 100644 --- a/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::AccessibilityReports do +RSpec.describe Gitlab::Ci::Reports::AccessibilityReports do let(:accessibility_report) { described_class.new } let(:url) { 'https://gitlab.com' } let(:data) do diff --git a/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb b/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb index 7cf43ceab32..41ebae863ee 100644 --- a/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::CoverageReports do +RSpec.describe Gitlab::Ci::Reports::CoverageReports do let(:coverage_report) { described_class.new } it { expect(coverage_report.files).to eq({}) } diff --git a/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb b/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb index bfab30543ed..5e94fe2bb3d 100644 --- a/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TerraformReports do +RSpec.describe Gitlab::Ci::Reports::TerraformReports do it 'initializes plans with and empty hash' do expect(subject.plans).to eq({}) end diff --git a/spec/lib/gitlab/ci/reports/test_case_spec.rb b/spec/lib/gitlab/ci/reports/test_case_spec.rb index b5883867983..8882defbd9e 100644 --- a/spec/lib/gitlab/ci/reports/test_case_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_case_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TestCase do +RSpec.describe Gitlab::Ci::Reports::TestCase do describe '#initialize' do let(:test_case) { described_class.new(params)} diff --git a/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb b/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb new file mode 100644 index 00000000000..70d82851125 --- /dev/null +++ b/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Ci::Reports::TestReportSummary do + let(:build_report_result_1) { build(:ci_build_report_result) } + let(:build_report_result_2) { build(:ci_build_report_result, :with_junit_success) } + let(:test_report_summary) { described_class.new([build_report_result_1, build_report_result_2]) } + + describe '#total' do + subject { test_report_summary.total } + + context 'when test report summary has several build report results' do + it 'returns test suite summary object' do + expect(subject).to be_a_kind_of(Gitlab::Ci::Reports::TestSuiteSummary) + end + end + end + + describe '#total_time' do + subject { test_report_summary.total_time } + + context 'when test report summary has several build report results' do + it 'returns the total' do + expect(subject).to eq(0.84) + end + end + end + + describe '#total_count' do + subject { test_report_summary.total_count } + + context 'when test report summary has several build report results' do + it 'returns the total count' do + expect(subject).to eq(4) + end + end + end + + describe '#success_count' do + subject { test_report_summary.success_count } + + context 'when test suite summary has several build report results' do + it 'returns the total success' do + expect(subject).to eq(2) + end + end + end + + describe '#failed_count' do + subject { test_report_summary.failed_count } + + context 'when test suite summary has several build report results' do + it 'returns the total failed' do + expect(subject).to eq(0) + end + end + end + + describe '#error_count' do + subject { test_report_summary.error_count } + + context 'when test suite summary has several build report results' do + it 'returns the total errored' do + expect(subject).to eq(2) + end + end + end + + describe '#skipped_count' do + subject { test_report_summary.skipped_count } + + context 'when test suite summary has several build report results' do + it 'returns the total skipped' do + expect(subject).to eq(0) + end + end + end + + describe '#test_suites' do + subject { test_report_summary.test_suites } + + context 'when test report summary has several build report results' do + it 'returns test suites grouped by name' do + expect(subject.keys).to eq(["rspec"]) + expect(subject.keys.size).to eq(1) + end + end + end +end diff --git a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb index d731afe1fff..3483dddca3a 100644 --- a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TestReportsComparer do +RSpec.describe Gitlab::Ci::Reports::TestReportsComparer do include TestReportsHelper let(:comparer) { described_class.new(base_reports, head_reports) } diff --git a/spec/lib/gitlab/ci/reports/test_reports_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_spec.rb index e51728496e1..502859852f2 100644 --- a/spec/lib/gitlab/ci/reports/test_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_reports_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TestReports do +RSpec.describe Gitlab::Ci::Reports::TestReports do include TestReportsHelper let(:test_reports) { described_class.new } diff --git a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb index 2d2179a690b..6bb6771678a 100644 --- a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TestSuiteComparer do +RSpec.describe Gitlab::Ci::Reports::TestSuiteComparer do include TestReportsHelper let(:comparer) { described_class.new(name, base_suite, head_suite) } diff --git a/spec/lib/gitlab/ci/reports/test_suite_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_spec.rb index e0b2593353a..c4c4d2c3704 100644 --- a/spec/lib/gitlab/ci/reports/test_suite_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_suite_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Reports::TestSuite do +RSpec.describe Gitlab::Ci::Reports::TestSuite do include TestReportsHelper let(:test_suite) { described_class.new('Rspec') } @@ -139,6 +139,41 @@ describe Gitlab::Ci::Reports::TestSuite do end end + describe '#+' do + let(:test_suite_2) { described_class.new('Rspec') } + + subject { test_suite + test_suite_2 } + + context 'when adding multiple suites together' do + before do + test_suite.add_test_case(test_case_success) + test_suite.add_test_case(test_case_failed) + end + + it 'returns a new test suite' do + expect(subject).to be_an_instance_of(described_class) + end + + it 'returns the suite name' do + expect(subject.name).to eq('Rspec') + end + + it 'returns the sum for total_time' do + expect(subject.total_time).to eq(3.33) + end + + it 'merges tests cases hash', :aggregate_failures do + test_suite_2.add_test_case(create_test_case_java_success) + + failed_keys = test_suite.test_cases['failed'].keys + success_keys = test_suite.test_cases['success'].keys + test_suite_2.test_cases['success'].keys + + expect(subject.test_cases['failed'].keys).to contain_exactly(*failed_keys) + expect(subject.test_cases['success'].keys).to contain_exactly(*success_keys) + end + end + end + Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type| describe "##{status_type}" do subject { test_suite.public_send("#{status_type}") } diff --git a/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb new file mode 100644 index 00000000000..12c96acdcf3 --- /dev/null +++ b/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Ci::Reports::TestSuiteSummary do + let(:build_report_result_1) { build(:ci_build_report_result) } + let(:build_report_result_2) { build(:ci_build_report_result, :with_junit_success) } + let(:test_suite_summary) { described_class.new([build_report_result_1, build_report_result_2]) } + + describe '#name' do + subject { test_suite_summary.name } + + context 'when test suite summary has several build report results' do + it 'returns the suite name' do + expect(subject).to eq("rspec") + end + end + end + + describe '#build_ids' do + subject { test_suite_summary.build_ids } + + context 'when test suite summary has several build report results' do + it 'returns the build ids' do + expect(subject).to contain_exactly(build_report_result_1.build_id, build_report_result_2.build_id) + end + end + end + + describe '#total_time' do + subject { test_suite_summary.total_time } + + context 'when test suite summary has several build report results' do + it 'returns the total time' do + expect(subject).to eq(0.84) + end + end + end + + describe '#success_count' do + subject { test_suite_summary.success_count } + + context 'when test suite summary has several build report results' do + it 'returns the total success' do + expect(subject).to eq(2) + end + end + end + + describe '#failed_count' do + subject { test_suite_summary.failed_count } + + context 'when test suite summary has several build report results' do + it 'returns the total failed' do + expect(subject).to eq(0) + end + end + end + + describe '#error_count' do + subject { test_suite_summary.error_count } + + context 'when test suite summary has several build report results' do + it 'returns the total errored' do + expect(subject).to eq(2) + end + end + end + + describe '#skipped_count' do + subject { test_suite_summary.skipped_count } + + context 'when test suite summary has several build report results' do + it 'returns the total skipped' do + expect(subject).to eq(0) + end + end + end + + describe '#total_count' do + subject { test_suite_summary.total_count } + + context 'when test suite summary has several build report results' do + it 'returns the total count' do + expect(subject).to eq(4) + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb index 6c67864855d..021b777a0ff 100644 --- a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Bridge::Factory do +RSpec.describe Gitlab::Ci::Status::Bridge::Factory do let(:user) { create(:user) } let(:project) { bridge.project } let(:status) { factory.fabricate! } diff --git a/spec/lib/gitlab/ci/status/build/action_spec.rb b/spec/lib/gitlab/ci/status/build/action_spec.rb index 3aae7e18d6d..de237183feb 100644 --- a/spec/lib/gitlab/ci/status/build/action_spec.rb +++ b/spec/lib/gitlab/ci/status/build/action_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Action do +RSpec.describe Gitlab::Ci::Status::Build::Action do let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb index 3841dae91c7..95920518793 100644 --- a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb +++ b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Cancelable do +RSpec.describe Gitlab::Ci::Status::Build::Cancelable do let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/canceled_spec.rb b/spec/lib/gitlab/ci/status/build/canceled_spec.rb index 4b43c78f1a7..e30a2211c8f 100644 --- a/spec/lib/gitlab/ci/status/build/canceled_spec.rb +++ b/spec/lib/gitlab/ci/status/build/canceled_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Canceled do +RSpec.describe Gitlab::Ci::Status::Build::Canceled do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/common_spec.rb b/spec/lib/gitlab/ci/status/build/common_spec.rb index 5114540708f..924ee5ee1a4 100644 --- a/spec/lib/gitlab/ci/status/build/common_spec.rb +++ b/spec/lib/gitlab/ci/status/build/common_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Common do +RSpec.describe Gitlab::Ci::Status::Build::Common do let(:user) { create(:user) } let(:build) { create(:ci_build) } let(:project) { build.project } diff --git a/spec/lib/gitlab/ci/status/build/created_spec.rb b/spec/lib/gitlab/ci/status/build/created_spec.rb index 6e3aa442810..49468674140 100644 --- a/spec/lib/gitlab/ci/status/build/created_spec.rb +++ b/spec/lib/gitlab/ci/status/build/created_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Created do +RSpec.describe Gitlab::Ci::Status::Build::Created do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/erased_spec.rb b/spec/lib/gitlab/ci/status/build/erased_spec.rb index af9c296da0c..75467cc6b31 100644 --- a/spec/lib/gitlab/ci/status/build/erased_spec.rb +++ b/spec/lib/gitlab/ci/status/build/erased_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Erased do +RSpec.describe Gitlab::Ci::Status::Build::Erased do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index 11be17bfc53..21eca97331e 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Factory do +RSpec.describe Gitlab::Ci::Status::Build::Factory do let(:user) { create(:user) } let(:project) { build.project } let(:status) { factory.fabricate! } diff --git a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb index 01500689619..0ff7c3796c0 100644 --- a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb +++ b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::FailedAllowed do +RSpec.describe Gitlab::Ci::Status::Build::FailedAllowed do let(:status) { double('core status') } let(:user) { double('user') } let(:build) { create(:ci_build, :failed, :allowed_to_fail) } diff --git a/spec/lib/gitlab/ci/status/build/failed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_spec.rb index 78f5214ca81..1d5069fe180 100644 --- a/spec/lib/gitlab/ci/status/build/failed_spec.rb +++ b/spec/lib/gitlab/ci/status/build/failed_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Failed do +RSpec.describe Gitlab::Ci::Status::Build::Failed do let(:build) { create(:ci_build, :script_failure) } let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/manual_spec.rb b/spec/lib/gitlab/ci/status/build/manual_spec.rb index bffe2c10d12..78193055139 100644 --- a/spec/lib/gitlab/ci/status/build/manual_spec.rb +++ b/spec/lib/gitlab/ci/status/build/manual_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Manual do +RSpec.describe Gitlab::Ci::Status::Build::Manual do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/pending_spec.rb b/spec/lib/gitlab/ci/status/build/pending_spec.rb index 64d57954c15..7b695d33877 100644 --- a/spec/lib/gitlab/ci/status/build/pending_spec.rb +++ b/spec/lib/gitlab/ci/status/build/pending_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Pending do +RSpec.describe Gitlab::Ci::Status::Build::Pending do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/play_spec.rb b/spec/lib/gitlab/ci/status/build/play_spec.rb index bb12a900b55..bb406623d2f 100644 --- a/spec/lib/gitlab/ci/status/build/play_spec.rb +++ b/spec/lib/gitlab/ci/status/build/play_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Play do +RSpec.describe Gitlab::Ci::Status::Build::Play do let(:user) { create(:user) } let(:project) { create(:project, :stubbed_repository) } let(:build) { create(:ci_build, :manual, project: project) } diff --git a/spec/lib/gitlab/ci/status/build/preparing_spec.rb b/spec/lib/gitlab/ci/status/build/preparing_spec.rb index 4d8945845ba..5bb18ac3799 100644 --- a/spec/lib/gitlab/ci/status/build/preparing_spec.rb +++ b/spec/lib/gitlab/ci/status/build/preparing_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Preparing do +RSpec.describe Gitlab::Ci::Status::Build::Preparing do subject do described_class.new(double('subject')) end diff --git a/spec/lib/gitlab/ci/status/build/retried_spec.rb b/spec/lib/gitlab/ci/status/build/retried_spec.rb index fce497d40a1..522228f0a1d 100644 --- a/spec/lib/gitlab/ci/status/build/retried_spec.rb +++ b/spec/lib/gitlab/ci/status/build/retried_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Retried do +RSpec.describe Gitlab::Ci::Status::Build::Retried do let(:build) { create(:ci_build, :retried) } let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/retryable_spec.rb b/spec/lib/gitlab/ci/status/build/retryable_spec.rb index 5b0ae315927..cb1cf85169d 100644 --- a/spec/lib/gitlab/ci/status/build/retryable_spec.rb +++ b/spec/lib/gitlab/ci/status/build/retryable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Retryable do +RSpec.describe Gitlab::Ci::Status::Build::Retryable do let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb b/spec/lib/gitlab/ci/status/build/scheduled_spec.rb index 8f87da10815..b0cd1ac4dc5 100644 --- a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb +++ b/spec/lib/gitlab/ci/status/build/scheduled_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Scheduled do +RSpec.describe Gitlab::Ci::Status::Build::Scheduled do let(:user) { create(:user) } let(:project) { create(:project, :stubbed_repository) } let(:build) { create(:ci_build, :scheduled, project: project) } diff --git a/spec/lib/gitlab/ci/status/build/skipped_spec.rb b/spec/lib/gitlab/ci/status/build/skipped_spec.rb index 7ce5142da78..0b998a52a57 100644 --- a/spec/lib/gitlab/ci/status/build/skipped_spec.rb +++ b/spec/lib/gitlab/ci/status/build/skipped_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Skipped do +RSpec.describe Gitlab::Ci::Status::Build::Skipped do let(:user) { create(:user) } subject do diff --git a/spec/lib/gitlab/ci/status/build/stop_spec.rb b/spec/lib/gitlab/ci/status/build/stop_spec.rb index d3e98400a53..7376afe0e83 100644 --- a/spec/lib/gitlab/ci/status/build/stop_spec.rb +++ b/spec/lib/gitlab/ci/status/build/stop_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Stop do +RSpec.describe Gitlab::Ci::Status::Build::Stop do let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/build/unschedule_spec.rb b/spec/lib/gitlab/ci/status/build/unschedule_spec.rb index c18fc3252b4..74002c7d0d7 100644 --- a/spec/lib/gitlab/ci/status/build/unschedule_spec.rb +++ b/spec/lib/gitlab/ci/status/build/unschedule_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Build::Unschedule do +RSpec.describe Gitlab::Ci::Status::Build::Unschedule do let(:status) { double('core status') } let(:user) { double('user') } diff --git a/spec/lib/gitlab/ci/status/canceled_spec.rb b/spec/lib/gitlab/ci/status/canceled_spec.rb index 6cfcea4fdde..a35efae5c57 100644 --- a/spec/lib/gitlab/ci/status/canceled_spec.rb +++ b/spec/lib/gitlab/ci/status/canceled_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Canceled do +RSpec.describe Gitlab::Ci::Status::Canceled do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/composite_spec.rb b/spec/lib/gitlab/ci/status/composite_spec.rb index 8a226b382b0..47bbc4169b6 100644 --- a/spec/lib/gitlab/ci/status/composite_spec.rb +++ b/spec/lib/gitlab/ci/status/composite_spec.rb @@ -2,15 +2,15 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Composite do +RSpec.describe Gitlab::Ci::Status::Composite do let_it_be(:pipeline) { create(:ci_pipeline) } before_all do - @statuses = HasStatus::STATUSES_ENUM.map do |status, idx| + @statuses = Ci::HasStatus::STATUSES_ENUM.map do |status, idx| [status, create(:ci_build, pipeline: pipeline, status: status, importing: true)] end.to_h - @statuses_with_allow_failure = HasStatus::STATUSES_ENUM.map do |status, idx| + @statuses_with_allow_failure = Ci::HasStatus::STATUSES_ENUM.map do |status, idx| [status, create(:ci_build, pipeline: pipeline, status: status, allow_failure: true, importing: true)] end.to_h end @@ -26,7 +26,7 @@ describe Gitlab::Ci::Status::Composite do end shared_examples 'validate all combinations' do |perms| - HasStatus::STATUSES_ENUM.keys.combination(perms).each do |statuses| + Ci::HasStatus::STATUSES_ENUM.keys.combination(perms).each do |statuses| context "with #{statuses.join(",")}" do it_behaves_like 'compares composite with SQL status' do let(:all_statuses) do @@ -38,7 +38,7 @@ describe Gitlab::Ci::Status::Composite do end end - HasStatus::STATUSES_ENUM.each do |allow_failure_status, _| + Ci::HasStatus::STATUSES_ENUM.each do |allow_failure_status, _| context "and allow_failure #{allow_failure_status}" do it_behaves_like 'compares composite with SQL status' do let(:all_statuses) do diff --git a/spec/lib/gitlab/ci/status/created_spec.rb b/spec/lib/gitlab/ci/status/created_spec.rb index aeb41e9cfc3..1ddced923f6 100644 --- a/spec/lib/gitlab/ci/status/created_spec.rb +++ b/spec/lib/gitlab/ci/status/created_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Created do +RSpec.describe Gitlab::Ci::Status::Created do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/extended_spec.rb b/spec/lib/gitlab/ci/status/extended_spec.rb index 8accfc4a2f9..3e1004754ba 100644 --- a/spec/lib/gitlab/ci/status/extended_spec.rb +++ b/spec/lib/gitlab/ci/status/extended_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Extended do +RSpec.describe Gitlab::Ci::Status::Extended do it 'requires subclass to implement matcher' do expect { described_class.matches?(double, double) } .to raise_error(NotImplementedError) diff --git a/spec/lib/gitlab/ci/status/external/common_spec.rb b/spec/lib/gitlab/ci/status/external/common_spec.rb index 983522fa2d6..6de08ce9281 100644 --- a/spec/lib/gitlab/ci/status/external/common_spec.rb +++ b/spec/lib/gitlab/ci/status/external/common_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::External::Common do +RSpec.describe Gitlab::Ci::Status::External::Common do let(:user) { create(:user) } let(:project) { external_status.project } let(:external_target_url) { 'http://example.gitlab.com/status' } diff --git a/spec/lib/gitlab/ci/status/external/factory_spec.rb b/spec/lib/gitlab/ci/status/external/factory_spec.rb index 9c11e42fc5a..a31a11cd14a 100644 --- a/spec/lib/gitlab/ci/status/external/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/external/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::External::Factory do +RSpec.describe Gitlab::Ci::Status::External::Factory do let(:user) { create(:user) } let(:project) { resource.project } let(:status) { factory.fabricate! } @@ -14,7 +14,7 @@ describe Gitlab::Ci::Status::External::Factory do end context 'when external status has a simple core status' do - HasStatus::AVAILABLE_STATUSES.each do |simple_status| + Ci::HasStatus::AVAILABLE_STATUSES.each do |simple_status| context "when core status is #{simple_status}" do let(:resource) do create(:generic_commit_status, status: simple_status, diff --git a/spec/lib/gitlab/ci/status/factory_spec.rb b/spec/lib/gitlab/ci/status/factory_spec.rb index 219eb53d9df..641cb0183d3 100644 --- a/spec/lib/gitlab/ci/status/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/factory_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Factory do +RSpec.describe Gitlab::Ci::Status::Factory do let(:user) { create(:user) } let(:fabricated_status) { factory.fabricate! } let(:factory) { described_class.new(resource, user) } context 'when object has a core status' do - HasStatus::AVAILABLE_STATUSES.each do |simple_status| + Ci::HasStatus::AVAILABLE_STATUSES.each do |simple_status| context "when simple core status is #{simple_status}" do let(:resource) { double('resource', status: simple_status) } diff --git a/spec/lib/gitlab/ci/status/failed_spec.rb b/spec/lib/gitlab/ci/status/failed_spec.rb index 5c7393fc8cf..e8bd728b740 100644 --- a/spec/lib/gitlab/ci/status/failed_spec.rb +++ b/spec/lib/gitlab/ci/status/failed_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Failed do +RSpec.describe Gitlab::Ci::Status::Failed do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/group/common_spec.rb b/spec/lib/gitlab/ci/status/group/common_spec.rb index 35fff30ea9d..2bfd816e45d 100644 --- a/spec/lib/gitlab/ci/status/group/common_spec.rb +++ b/spec/lib/gitlab/ci/status/group/common_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Group::Common do +RSpec.describe Gitlab::Ci::Status::Group::Common do subject do Gitlab::Ci::Status::Core.new(double, double) .extend(described_class) diff --git a/spec/lib/gitlab/ci/status/group/factory_spec.rb b/spec/lib/gitlab/ci/status/group/factory_spec.rb index be76a1d5a65..6267b26aa78 100644 --- a/spec/lib/gitlab/ci/status/group/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/group/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Group::Factory do +RSpec.describe Gitlab::Ci::Status::Group::Factory do it 'inherits from the core factory' do expect(described_class) .to be < Gitlab::Ci::Status::Factory diff --git a/spec/lib/gitlab/ci/status/manual_spec.rb b/spec/lib/gitlab/ci/status/manual_spec.rb index 0839452ec22..a9203438898 100644 --- a/spec/lib/gitlab/ci/status/manual_spec.rb +++ b/spec/lib/gitlab/ci/status/manual_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Manual do +RSpec.describe Gitlab::Ci::Status::Manual do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/pending_spec.rb b/spec/lib/gitlab/ci/status/pending_spec.rb index 5f830e5bb56..0e47b19d9c1 100644 --- a/spec/lib/gitlab/ci/status/pending_spec.rb +++ b/spec/lib/gitlab/ci/status/pending_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Pending do +RSpec.describe Gitlab::Ci::Status::Pending do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb index 664915ba552..8fd974972e4 100644 --- a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Pipeline::Blocked do +RSpec.describe Gitlab::Ci::Status::Pipeline::Blocked do let(:pipeline) { double('pipeline') } subject do diff --git a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb index d3251d138b8..575acc48a61 100644 --- a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Pipeline::Common do +RSpec.describe Gitlab::Ci::Status::Pipeline::Common do let(:user) { create(:user) } let(:project) { create(:project, :private) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb index aba403de712..1302c2069ff 100644 --- a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Pipeline::Delayed do +RSpec.describe Gitlab::Ci::Status::Pipeline::Delayed do let(:pipeline) { double('pipeline') } subject do diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb index 838154759cb..a6f23180860 100644 --- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Pipeline::Factory do +RSpec.describe Gitlab::Ci::Status::Pipeline::Factory do let(:user) { create(:user) } let(:project) { pipeline.project } let(:status) { factory.fabricate! } @@ -13,7 +13,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do end context 'when pipeline has a core status' do - (HasStatus::AVAILABLE_STATUSES - HasStatus::BLOCKED_STATUS).each do |simple_status| + (Ci::HasStatus::AVAILABLE_STATUSES - Ci::HasStatus::BLOCKED_STATUS).each do |simple_status| context "when core status is #{simple_status}" do let(:pipeline) { create(:ci_pipeline, status: simple_status) } diff --git a/spec/lib/gitlab/ci/status/preparing_spec.rb b/spec/lib/gitlab/ci/status/preparing_spec.rb index 33f6bab8d65..6d33eb77560 100644 --- a/spec/lib/gitlab/ci/status/preparing_spec.rb +++ b/spec/lib/gitlab/ci/status/preparing_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Preparing do +RSpec.describe Gitlab::Ci::Status::Preparing do subject do described_class.new(double('subject'), nil) end diff --git a/spec/lib/gitlab/ci/status/running_spec.rb b/spec/lib/gitlab/ci/status/running_spec.rb index 75ff58c5c98..fbc7bfd81b3 100644 --- a/spec/lib/gitlab/ci/status/running_spec.rb +++ b/spec/lib/gitlab/ci/status/running_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Running do +RSpec.describe Gitlab::Ci::Status::Running do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/scheduled_spec.rb b/spec/lib/gitlab/ci/status/scheduled_spec.rb index a0374e1a87b..4a1dae937ca 100644 --- a/spec/lib/gitlab/ci/status/scheduled_spec.rb +++ b/spec/lib/gitlab/ci/status/scheduled_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Scheduled do +RSpec.describe Gitlab::Ci::Status::Scheduled do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/skipped_spec.rb b/spec/lib/gitlab/ci/status/skipped_spec.rb index 7f68d4a2fa9..f402bbe5221 100644 --- a/spec/lib/gitlab/ci/status/skipped_spec.rb +++ b/spec/lib/gitlab/ci/status/skipped_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Skipped do +RSpec.describe Gitlab::Ci::Status::Skipped do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/stage/common_spec.rb b/spec/lib/gitlab/ci/status/stage/common_spec.rb index 26ff0e901fd..bbd2ce6c83b 100644 --- a/spec/lib/gitlab/ci/status/stage/common_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/common_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Stage::Common do +RSpec.describe Gitlab::Ci::Status::Stage::Common do let(:user) { create(:user) } let(:project) { create(:project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) } diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb index 317756ea13c..e0f5531f370 100644 --- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Stage::Factory do +RSpec.describe Gitlab::Ci::Status::Stage::Factory do let(:user) { create(:user) } let(:project) { create(:project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) } @@ -24,7 +24,7 @@ describe Gitlab::Ci::Status::Stage::Factory do end context 'when stage has a core status' do - (HasStatus::AVAILABLE_STATUSES - %w(manual skipped scheduled)).each do |core_status| + (Ci::HasStatus::AVAILABLE_STATUSES - %w(manual skipped scheduled)).each do |core_status| context "when core status is #{core_status}" do before do create(:ci_build, pipeline: pipeline, stage: 'test', status: core_status) @@ -68,7 +68,7 @@ describe Gitlab::Ci::Status::Stage::Factory do end context 'when stage has manual builds' do - (HasStatus::BLOCKED_STATUS + ['skipped']).each do |core_status| + (Ci::HasStatus::BLOCKED_STATUS + ['skipped']).each do |core_status| context "when status is #{core_status}" do before do create(:ci_build, pipeline: pipeline, stage: 'test', status: core_status) diff --git a/spec/lib/gitlab/ci/status/stage/play_manual_spec.rb b/spec/lib/gitlab/ci/status/stage/play_manual_spec.rb index bdcbfed918f..25b79ff2099 100644 --- a/spec/lib/gitlab/ci/status/stage/play_manual_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/play_manual_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Stage::PlayManual do +RSpec.describe Gitlab::Ci::Status::Stage::PlayManual do let(:stage) { double('stage') } let(:play_manual) { described_class.new(stage) } diff --git a/spec/lib/gitlab/ci/status/success_spec.rb b/spec/lib/gitlab/ci/status/success_spec.rb index d4b3a9f12cc..2d1c50448d4 100644 --- a/spec/lib/gitlab/ci/status/success_spec.rb +++ b/spec/lib/gitlab/ci/status/success_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::Success do +RSpec.describe Gitlab::Ci::Status::Success do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/status/success_warning_spec.rb b/spec/lib/gitlab/ci/status/success_warning_spec.rb index af952011e21..86b826ad272 100644 --- a/spec/lib/gitlab/ci/status/success_warning_spec.rb +++ b/spec/lib/gitlab/ci/status/success_warning_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::SuccessWarning do +RSpec.describe Gitlab::Ci::Status::SuccessWarning do let(:status) { double('status') } subject do diff --git a/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb b/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb index ed00dac8560..de18198c6c2 100644 --- a/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb +++ b/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Status::WaitingForResource do +RSpec.describe Gitlab::Ci::Status::WaitingForResource do subject do described_class.new(double('subject'), double('user')) end diff --git a/spec/lib/gitlab/ci/templates/Jobs/build_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/build_gitlab_ci_yaml_spec.rb index b2a9e3f5cf4..4f8faa5ddb1 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/build_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/build_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Jobs/Build.gitlab-ci.yml' do +RSpec.describe 'Jobs/Build.gitlab-ci.yml' do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/Build') } describe 'the created pipeline' do diff --git a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb index 9c5b2fd5099..e685ad3b46e 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Jobs/Code-Quality.gitlab-ci.yml' do +RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml' do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/Code-Quality') } describe 'the created pipeline' do diff --git a/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb index a6ae23c85d3..ea9bd5bd02c 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Jobs/Deploy.gitlab-ci.yml' do +RSpec.describe 'Jobs/Deploy.gitlab-ci.yml' do subject(:template) do <<~YAML stages: diff --git a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb index 2186bf038eb..f475785be98 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Jobs/Test.gitlab-ci.yml' do +RSpec.describe 'Jobs/Test.gitlab-ci.yml' do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/Test') } describe 'the created pipeline' do diff --git a/spec/lib/gitlab/ci/templates/Jobs/browser_performance_testing_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Verify/load_performance_testing_gitlab_ci_yaml_spec.rb index 54c3500b0a0..9711df55226 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/browser_performance_testing_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Verify/load_performance_testing_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do +RSpec.describe 'Verify/Load-Performance-Testing.gitlab-ci.yml' do subject(:template) do <<~YAML stages: @@ -10,7 +10,7 @@ describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do - performance include: - - template: 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' + - template: 'Verify/Load-Performance-Testing.gitlab-ci.yml' placeholder: script: @@ -20,11 +20,7 @@ describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do describe 'the created pipeline' do let(:user) { create(:admin) } - let(:project) do - create(:project, :repository, variables: [ - build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true') - ]) - end + let(:project) { create(:project, :repository) } let(:default_branch) { 'master' } let(:pipeline_ref) { default_branch } @@ -43,32 +39,26 @@ describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do expect(pipeline.errors).to be_empty end - shared_examples_for 'performance job on tag or branch' do + shared_examples_for 'load_performance job on tag or branch' do it 'by default' do - expect(build_names).to include('performance') - end - - it 'when PERFORMANCE_DISABLED' do - create(:ci_variable, project: project, key: 'PERFORMANCE_DISABLED', value: '1') - - expect(build_names).not_to include('performance') + expect(build_names).to include('load_performance') end end context 'on master' do - it_behaves_like 'performance job on tag or branch' + it_behaves_like 'load_performance job on tag or branch' end context 'on another branch' do let(:pipeline_ref) { 'feature' } - it_behaves_like 'performance job on tag or branch' + it_behaves_like 'load_performance job on tag or branch' end context 'on tag' do let(:pipeline_ref) { 'v1.0.0' } - it_behaves_like 'performance job on tag or branch' + it_behaves_like 'load_performance job on tag or branch' end context 'on merge request' do diff --git a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb index af6ec25b9d6..4d90e7ca9e6 100644 --- a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Auto-DevOps.gitlab-ci.yml' do +RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps') } describe 'the created pipeline' do @@ -37,6 +37,7 @@ describe 'Auto-DevOps.gitlab-ci.yml' do context 'when the project is set for deployment to AWS' do let(:platform_value) { 'ECS' } + let(:review_prod_build_names) { build_names.select {|n| n.include?('review') || n.include?('production')} } before do create(:ci_variable, project: project, key: 'AUTO_DEVOPS_PLATFORM_TARGET', value: platform_value) @@ -67,8 +68,15 @@ describe 'Auto-DevOps.gitlab-ci.yml' do end it 'creates an ECS deployment job for production only' do - expect(build_names).not_to include('review_ecs') - expect(build_names).to include('production_ecs') + expect(review_prod_build_names).to contain_exactly('production_ecs') + end + + context 'with FARGATE as a launch type' do + let(:platform_value) { 'FARGATE' } + + it 'creates a FARGATE deployment job for production only' do + expect(review_prod_build_names).to contain_exactly('production_fargate') + end end context 'and we are not on the default branch' do @@ -79,15 +87,22 @@ describe 'Auto-DevOps.gitlab-ci.yml' do project.repository.create_branch(pipeline_branch) end - it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do - let(:job_name) { 'review_ecs' } + %w(review_ecs review_fargate).each do |job| + it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do + let(:job_name) { job } + end end it 'creates an ECS deployment job for review only' do - expect(build_names).to include('review_ecs') - expect(build_names).not_to include('production_ecs') - expect(build_names).not_to include('review') - expect(build_names).not_to include('production') + expect(review_prod_build_names).to contain_exactly('review_ecs') + end + + context 'with FARGATE as a launch type' do + let(:platform_value) { 'FARGATE' } + + it 'creates an FARGATE deployment job for review only' do + expect(review_prod_build_names).to contain_exactly('review_fargate') + end end end @@ -190,6 +205,7 @@ describe 'Auto-DevOps.gitlab-ci.yml' do 'Buildpack' | { 'README.md' => '' } | { 'BUILDPACK_URL' => 'http://example.com' } | %w(build test) | %w() 'Explicit set' | { 'README.md' => '' } | { 'AUTO_DEVOPS_EXPLICITLY_ENABLED' => '1' } | %w(build test) | %w() 'Explicit unset' | { 'README.md' => '' } | { 'AUTO_DEVOPS_EXPLICITLY_ENABLED' => '0' } | %w() | %w(build test) + 'DOCKERFILE_PATH' | { 'README.md' => '' } | { 'DOCKERFILE_PATH' => 'Docker.file' } | %w(build test) | %w() 'Dockerfile' | { 'Dockerfile' => '' } | {} | %w(build test) | %w() 'Clojure' | { 'project.clj' => '' } | {} | %w(build test) | %w() 'Go modules' | { 'go.mod' => '' } | {} | %w(build test) | %w() diff --git a/spec/lib/gitlab/ci/templates/managed_cluster_applications_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/managed_cluster_applications_gitlab_ci_yaml_spec.rb index 2a6314755ef..0e458e01a2c 100644 --- a/spec/lib/gitlab/ci/templates/managed_cluster_applications_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/managed_cluster_applications_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Managed-Cluster-Applications.gitlab-ci.yml' do +RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Managed-Cluster-Applications') } describe 'the created pipeline' do diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb index bc3d5b89220..def4d1b3bf6 100644 --- a/spec/lib/gitlab/ci/templates/templates_spec.rb +++ b/spec/lib/gitlab/ci/templates/templates_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'CI YML Templates' do +RSpec.describe 'CI YML Templates' do subject { Gitlab::Ci::YamlProcessor.new(content) } let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) } diff --git a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb index 92b3e5562a9..a2903391c6f 100644 --- a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb +++ b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do +RSpec.describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do include ChunkedIOHelpers let_it_be(:build) { create(:ci_build, :running) } diff --git a/spec/lib/gitlab/ci/trace/section_parser_spec.rb b/spec/lib/gitlab/ci/trace/section_parser_spec.rb index 24ce4d34411..b6bb52a5c06 100644 --- a/spec/lib/gitlab/ci/trace/section_parser_spec.rb +++ b/spec/lib/gitlab/ci/trace/section_parser_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Trace::SectionParser do +RSpec.describe Gitlab::Ci::Trace::SectionParser do def lines_with_pos(text) pos = 0 StringIO.new(text).each_line do |line| diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index ea79073840d..568c10bbac2 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do +RSpec.describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do let_it_be(:build) { create(:ci_build, :running) } before do diff --git a/spec/lib/gitlab/ci/trace_spec.rb b/spec/lib/gitlab/ci/trace_spec.rb index 574c2b73722..85edf27d3e7 100644 --- a/spec/lib/gitlab/ci/trace_spec.rb +++ b/spec/lib/gitlab/ci/trace_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state do +RSpec.describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state do let(:build) { create(:ci_build) } let(:trace) { described_class.new(build) } diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb index 1bdca753cd3..eba2f29836d 100644 --- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Variables::Collection::Item do +RSpec.describe Gitlab::Ci::Variables::Collection::Item do let(:variable_key) { 'VAR' } let(:variable_value) { 'something' } let(:expected_value) { variable_value } diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb index 59b9f7d4fb9..ac84313ad9f 100644 --- a/spec/lib/gitlab/ci/variables/collection_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Ci::Variables::Collection do +RSpec.describe Gitlab::Ci::Variables::Collection do describe '.new' do it 'can be initialized with an array' do variable = { key: 'VAR', value: 'value', public: true, masked: false } diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 1668149d8f5..5c6d748d66c 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' module Gitlab module Ci - describe YamlProcessor do + RSpec.describe YamlProcessor do include StubRequests subject { described_class.new(config, user: nil) } @@ -435,6 +435,153 @@ module Gitlab end end + describe '#warnings' do + before do + stub_feature_flags(ci_raise_job_rules_without_workflow_rules_warning: true) + end + + context 'when a warning is raised in a given entry' do + let(:config) do + <<-EOYML + rspec: + script: rspec + rules: + - if: '$VAR == "value"' + EOYML + end + + it 'is propagated all the way up to the processor' do + expect(subject.warnings).to contain_exactly('jobs:rspec uses `rules` without defining `workflow:rules`') + end + end + + context 'when a warning is raised together with errors' do + let(:config) do + <<-EOYML + rspec: + script: rspec + rules: + - if: '$VAR == "value"' + invalid: + script: echo + artifacts: + - wrong_key: value + EOYML + end + + it 'is propagated all the way up into the raised exception' do + expect { subject }.to raise_error do |error| + expect(error).to be_a(described_class::ValidationError) + expect(error.message).to eq('jobs:invalid:artifacts config should be a hash') + expect(error.warnings).to contain_exactly('jobs:rspec uses `rules` without defining `workflow:rules`') + end + end + end + + context 'when error is raised before composing the config' do + let(:config) do + <<-EOYML + include: unknown/file.yml + rspec: + script: rspec + rules: + - if: '$VAR == "value"' + EOYML + end + + it 'raises an exception with empty warnings array' do + expect { subject }.to raise_error do |error| + expect(error).to be_a(described_class::ValidationError) + expect(error.message).to eq('Local file `unknown/file.yml` does not have project!') + expect(error.warnings).to be_empty + end + end + end + + context 'when error is raised after composing the config with warnings' do + shared_examples 'has warnings and expected error' do |error_message| + it 'raises an exception including warnings' do + expect { subject }.to raise_error do |error| + expect(error).to be_a(described_class::ValidationError) + expect(error.message).to match(error_message) + expect(error.warnings).to be_present + end + end + end + + context 'when stage does not exist' do + let(:config) do + <<-EOYML + rspec: + stage: custom_stage + script: rspec + rules: + - if: '$VAR == "value"' + EOYML + end + + it_behaves_like 'has warnings and expected error', /rspec job: chosen stage does not exist/ + end + + context 'job dependency does not exist' do + let(:config) do + <<-EOYML + build: + stage: build + script: echo + rules: + - if: '$VAR == "value"' + test: + stage: test + script: echo + needs: [unknown_job] + EOYML + end + + it_behaves_like 'has warnings and expected error', /test job: undefined need: unknown_job/ + end + + context 'job dependency defined in later stage' do + let(:config) do + <<-EOYML + build: + stage: build + script: echo + needs: [test] + rules: + - if: '$VAR == "value"' + test: + stage: test + script: echo + EOYML + end + + it_behaves_like 'has warnings and expected error', /build job: need test is not defined in prior stages/ + end + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(ci_raise_job_rules_without_workflow_rules_warning: false) + end + + context 'job rules used without workflow rules' do + let(:config) do + <<-EOYML + rspec: + script: rspec + rules: + - if: '$VAR == "value"' + EOYML + end + + it 'does not raise the warning' do + expect(subject.warnings).to be_empty + end + end + end + end + describe 'only / except policies validations' do context 'when `only` has an invalid value' do let(:config) { { rspec: { script: "rspec", type: "test", only: only } } } @@ -1397,6 +1544,9 @@ module Gitlab tag_name: "$CI_COMMIT_TAG", name: "Release $CI_TAG_NAME", description: "./release_changelog.txt", + ref: 'b3235930aa443112e639f941c69c578912189bdd', + released_at: '2019-03-15T08:00:00Z', + milestones: %w[m1 m2 m3], assets: { links: [ { @@ -2514,7 +2664,7 @@ module Gitlab it 'returns errors and empty configuration' do expect(subject.valid?).to eq(false) expect(subject.errors).to eq(['Invalid configuration format']) - expect(subject.content).to be_blank + expect(subject.config).to be_blank end end @@ -2524,7 +2674,7 @@ module Gitlab it 'returns errors and empty configuration' do expect(subject.valid?).to eq(false) expect(subject.errors).to eq(['jobs:rspec:tags config should be an array of strings']) - expect(subject.content).to be_blank + expect(subject.config).to be_blank end end @@ -2536,7 +2686,7 @@ module Gitlab expect(subject.errors).to contain_exactly( 'jobs:rspec config contains unknown keys: bad_tags', 'jobs:rspec rules should be an array of hashes') - expect(subject.content).to be_blank + expect(subject.config).to be_blank end end @@ -2546,7 +2696,7 @@ module Gitlab it 'returns errors and empty configuration' do expect(subject.valid?).to eq(false) expect(subject.errors).to eq(['Please provide content of .gitlab-ci.yml']) - expect(subject.content).to be_blank + expect(subject.config).to be_blank end end @@ -2556,7 +2706,7 @@ module Gitlab it 'returns errors and empty configuration' do expect(subject.valid?).to eq(false) expect(subject.errors).to eq(['Unknown alias: bad_alias']) - expect(subject.content).to be_blank + expect(subject.config).to be_blank end end @@ -2566,7 +2716,7 @@ module Gitlab it 'returns errors and empty configuration' do expect(subject.valid?).to eq(true) expect(subject.errors).to be_empty - expect(subject.content).to be_present + expect(subject.config).to be_present end end end |