Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/root_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/root_spec.rb46
1 files changed, 34 insertions, 12 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb
index d862fbf5b78..749d1386ed9 100644
--- a/spec/lib/gitlab/ci/config/entry/root_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb
@@ -3,7 +3,9 @@
require 'spec_helper'
RSpec.describe Gitlab::Ci::Config::Entry::Root do
- let(:root) { described_class.new(hash) }
+ let(:user) {}
+ let(:project) {}
+ let(:root) { described_class.new(hash, user: user, project: project) }
describe '.nodes' do
it 'returns a hash' do
@@ -53,6 +55,37 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
}
end
+ context 'when deprecated types keyword is defined' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+
+ let(:hash) do
+ { types: %w(test deploy),
+ rspec: { script: 'rspec' } }
+ end
+
+ before do
+ root.compose!
+ end
+
+ it 'returns array of types as stages with a warning' do
+ expect(root.stages_value).to eq %w[test deploy]
+ expect(root.warnings).to match_array(["root `types` is deprecated in 9.0 and will be removed in 15.0."])
+ end
+
+ it 'logs usage of types keyword' do
+ expect(Gitlab::AppJsonLogger).to(
+ receive(:info)
+ .with(event: 'ci_used_deprecated_keyword',
+ entry: root[:stages].key.to_s,
+ user_id: user.id,
+ project_id: project.id)
+ )
+
+ root.compose!
+ end
+ end
+
describe '#compose!' do
before do
root.compose!
@@ -108,17 +141,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
expect(root.stages_value).to eq %w[build pages release]
end
end
-
- context 'when deprecated types key defined' do
- let(:hash) do
- { types: %w(test deploy),
- rspec: { script: 'rspec' } }
- end
-
- it 'returns array of types as stages' do
- expect(root.stages_value).to eq %w[test deploy]
- end
- end
end
describe '#jobs_value' do