diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 03:07:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 03:07:23 +0300 |
commit | afd8f58f2d0d42d21496fe4652c1664add9b68b7 (patch) | |
tree | 38741f62cac6fafb42d30632596db951ec955850 /spec/requests | |
parent | beabc7d164276a8bb35c2b497a0c4dc0dc824e3c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/ci/group_environment_scopes_spec.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb b/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb new file mode 100644 index 00000000000..13a3a128979 --- /dev/null +++ b/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Query.group(fullPath).environmentScopes', feature_category: :secrets_management do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let(:expected_environment_scopes) do + %w[ + group1_environment1 + group1_environment2 + group2_environment3 + group2_environment4 + group2_environment5 + group2_environment6 + ] + end + + let(:query) do + %( + query { + group(fullPath: "#{group.full_path}") { + environmentScopes#{environment_scopes_params} { + nodes { + name + } + } + } + } + ) + end + + before do + group.add_developer(user) + expected_environment_scopes.each_with_index do |env, index| + create(:ci_group_variable, group: group, key: "var#{index + 1}", environment_scope: env) + end + end + + context 'when query has no parameters' do + let(:environment_scopes_params) { "" } + + it 'returns all avaiable environment scopes' do + post_graphql(query, current_user: user) + + expect(graphql_data.dig('group', 'environmentScopes', 'nodes')).to eq( + expected_environment_scopes.map { |env_scope| { 'name' => env_scope } } + ) + end + end + + context 'when query has search parameters' do + let(:environment_scopes_params) { "(search: \"group1\")" } + + it 'returns only environment scopes with group1 prefix' do + post_graphql(query, current_user: user) + + expect(graphql_data.dig('group', 'environmentScopes', 'nodes')).to eq( + [ + { 'name' => 'group1_environment1' }, + { 'name' => 'group1_environment2' } + ] + ) + end + end +end |