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/finders/ci/variables_finder_spec.rb')
-rw-r--r--spec/finders/ci/variables_finder_spec.rb65
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