diff options
author | Phil Hughes <me@iamphill.com> | 2017-09-05 09:21:36 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-09-05 09:21:36 +0100 |
commit | 365adcf6a3bd684abfa9aac3b47e53c1eb41bac6 (patch) | |
tree | 7787c1190dc1393a5b91c5e882e77a6df26f2b2d /spec/lib/gitlab/ci/config/entry/policy_spec.rb | |
parent | 78b0c35ce71b2e6083d655c47977766bf56fbe72 (diff) | |
parent | d4ec63186b106bbee4bde890b7c30b14a7748339 (diff) | |
download | gitlab-ce-365adcf6a3bd684abfa9aac3b47e53c1eb41bac6.tar.gz |
Merge branch 'master' into breadcrumbs-improvements
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/policy_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/policy_spec.rb | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/policy_spec.rb b/spec/lib/gitlab/ci/config/entry/policy_spec.rb index 36a84da4a52..5e83abf645b 100644 --- a/spec/lib/gitlab/ci/config/entry/policy_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/policy_spec.rb @@ -16,8 +16,8 @@ describe Gitlab::Ci::Config::Entry::Policy do end describe '#value' do - it 'returns key value' do - expect(entry.value).to eq config + it 'returns refs hash' do + expect(entry.value).to eq(refs: config) end end end @@ -56,6 +56,50 @@ describe Gitlab::Ci::Config::Entry::Policy do end end + context 'when using complex policy' do + context 'when specifiying refs policy' do + let(:config) { { refs: ['master'] } } + + it 'is a correct configuraton' do + expect(entry).to be_valid + expect(entry.value).to eq(refs: %w[master]) + end + end + + context 'when specifying kubernetes policy' do + let(:config) { { kubernetes: 'active' } } + + it 'is a correct configuraton' do + expect(entry).to be_valid + expect(entry.value).to eq(kubernetes: 'active') + end + end + + context 'when specifying invalid kubernetes policy' do + let(:config) { { kubernetes: 'something' } } + + it 'reports an error about invalid policy' do + expect(entry.errors).to include /unknown value: something/ + end + end + + context 'when specifying unknown policy' do + let(:config) { { refs: ['master'], invalid: :something } } + + it 'returns error about invalid key' do + expect(entry.errors).to include /unknown keys: invalid/ + end + end + + context 'when policy is empty' do + let(:config) { {} } + + it 'is not a valid configuration' do + expect(entry.errors).to include /can't be blank/ + end + end + end + context 'when policy strategy does not match' do let(:config) { 'string strategy' } |