diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/finders/ci | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/finders/ci')
-rw-r--r-- | spec/finders/ci/variables_finder_spec.rb | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/spec/finders/ci/variables_finder_spec.rb b/spec/finders/ci/variables_finder_spec.rb index cd5f950ca8e..683788452cc 100644 --- a/spec/finders/ci/variables_finder_spec.rb +++ b/spec/finders/ci/variables_finder_spec.rb @@ -3,42 +3,57 @@ require 'spec_helper' RSpec.describe Ci::VariablesFinder do - let!(:project) { create(:project) } - let!(:params) { {} } + shared_examples 'scoped variables' do + describe '#initialize' do + subject { described_class.new(owner, params) } - let!(:var1) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'staging') } - let!(:var2) { create(:ci_variable, project: project, key: 'key2', environment_scope: 'staging') } - let!(:var3) { create(:ci_variable, project: project, key: 'key2', environment_scope: 'production') } + context 'without key filter' do + let!(:params) { {} } - describe '#initialize' do - subject { described_class.new(project, params) } - - context 'without key filter' do - let!(:params) { {} } - - it 'raises an error' do - expect { subject }.to raise_error(ArgumentError, 'Please provide params[:key]') + it 'raises an error' do + expect { subject }.to raise_error(ArgumentError, 'Please provide params[:key]') + end end end - end - describe '#execute' do - subject { described_class.new(project.reload, params).execute } + describe '#execute' do + subject { described_class.new(owner.reload, params).execute } - context 'with key filter' do - let!(:params) { { key: 'key1' } } + context 'with key filter' do + let!(:params) { { key: 'key1' } } - it 'returns var1' do - expect(subject).to contain_exactly(var1) + it 'returns var1' do + expect(subject).to contain_exactly(var1) + end end - end - context 'with key and environment_scope filter' do - let!(:params) { { key: 'key2', filter: { environment_scope: 'staging' } } } + context 'with key and environment_scope filter' do + let!(:params) { { key: 'key2', filter: { environment_scope: 'staging' } } } - it 'returns var2' do - expect(subject).to contain_exactly(var2) + it 'returns var2' do + expect(subject).to contain_exactly(var2) + end end end end + + context 'for a project' do + let(:owner) { create(:project) } + + let!(:var1) { create(:ci_variable, project: owner, key: 'key1', environment_scope: 'staging') } + let!(:var2) { create(:ci_variable, project: owner, key: 'key2', environment_scope: 'staging') } + let!(:var3) { create(:ci_variable, project: owner, key: 'key2', environment_scope: 'production') } + + include_examples 'scoped variables' + end + + context 'for a group' do + let(:owner) { create(:group) } + + let!(:var1) { create(:ci_group_variable, group: owner, key: 'key1', environment_scope: 'staging') } + let!(:var2) { create(:ci_group_variable, group: owner, key: 'key2', environment_scope: 'staging') } + let!(:var3) { create(:ci_group_variable, group: owner, key: 'key2', environment_scope: 'production') } + + include_examples 'scoped variables' + end end |