diff options
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/graphql_helpers.rb | 25 | ||||
-rw-r--r-- | spec/support/helpers/ldap_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/license_helper.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/login_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/migrations_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/stub_configuration.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/stub_gitlab_calls.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/stub_object_storage.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/test_env.rb | 5 | ||||
-rw-r--r-- | spec/support/helpers/workhorse_helpers.rb | 3 |
10 files changed, 46 insertions, 1 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index beb346b2855..4d2ad165fd6 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -172,6 +172,31 @@ module GraphqlHelpers post_graphql(mutation.query, current_user: current_user, variables: mutation.variables) end + # this implements GraphQL multipart request v2 + # https://github.com/jaydenseric/graphql-multipart-request-spec/tree/v2.0.0-alpha.2 + # this is simplified and do not support file deduplication + def mutation_to_apollo_uploads_param(mutation, files: []) + operations = { 'query' => mutation.query, 'variables' => mutation.variables } + map = {} + extracted_files = {} + + files.each_with_index do |file_path, idx| + apollo_idx = (idx + 1).to_s + parent_dig_path = file_path[0..-2] + file_key = file_path[-1] + + parent = operations['variables'] + parent = parent.dig(*parent_dig_path) unless parent_dig_path.empty? + + extracted_files[apollo_idx] = parent[file_key] + parent[file_key] = nil + + map[apollo_idx] = ["variables.#{file_path.join('.')}"] + end + + { operations: operations.to_json, map: map.to_json }.merge(extracted_files) + end + # Raises an error if no data is found def graphql_data json_response['data'] || (raise NoData, graphql_errors) diff --git a/spec/support/helpers/ldap_helpers.rb b/spec/support/helpers/ldap_helpers.rb index dce8a3803f5..0549c56c753 100644 --- a/spec/support/helpers/ldap_helpers.rb +++ b/spec/support/helpers/ldap_helpers.rb @@ -70,3 +70,5 @@ module LdapHelpers .to receive(:ldap_search).and_raise(Gitlab::Auth::LDAP::LDAPConnectionError) end end + +LdapHelpers.include_if_ee('EE::LdapHelpers') diff --git a/spec/support/helpers/license_helper.rb b/spec/support/helpers/license_helper.rb index 4aaad55a8ef..a1defba9ccb 100644 --- a/spec/support/helpers/license_helper.rb +++ b/spec/support/helpers/license_helper.rb @@ -6,3 +6,5 @@ module LicenseHelpers # do nothing end end + +LicenseHelpers.prepend_if_ee('EE::LicenseHelpers') diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb index 2b508ee6f2c..140ad173d38 100644 --- a/spec/support/helpers/login_helpers.rb +++ b/spec/support/helpers/login_helpers.rb @@ -211,3 +211,5 @@ module LoginHelpers allow(Gitlab::Auth::Saml::Config).to receive_messages({ options: { name: 'saml', groups_attribute: 'groups', external_groups: groups, args: {} } }) end end + +LoginHelpers.prepend_if_ee('EE::LoginHelpers') diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index 2727ab7fb1e..a3145ed91bd 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -133,3 +133,5 @@ module MigrationsHelpers end end end + +MigrationsHelpers.prepend_if_ee('EE::MigrationsHelpers') diff --git a/spec/support/helpers/stub_configuration.rb b/spec/support/helpers/stub_configuration.rb index f364e4fd158..0dc6e851190 100644 --- a/spec/support/helpers/stub_configuration.rb +++ b/spec/support/helpers/stub_configuration.rb @@ -149,3 +149,5 @@ end require_relative '../../../ee/spec/support/helpers/ee/stub_configuration' if Dir.exist?("#{__dir__}/../../../ee") + +StubConfiguration.prepend_if_ee('EE::StubConfiguration') diff --git a/spec/support/helpers/stub_gitlab_calls.rb b/spec/support/helpers/stub_gitlab_calls.rb index 7d10cffe920..e3dde888277 100644 --- a/spec/support/helpers/stub_gitlab_calls.rb +++ b/spec/support/helpers/stub_gitlab_calls.rb @@ -139,3 +139,5 @@ module StubGitlabCalls JSON.parse f end end + +StubGitlabCalls.prepend_if_ee('EE::StubGitlabCalls') diff --git a/spec/support/helpers/stub_object_storage.rb b/spec/support/helpers/stub_object_storage.rb index e5b8bb712bb..3f7002b8768 100644 --- a/spec/support/helpers/stub_object_storage.rb +++ b/spec/support/helpers/stub_object_storage.rb @@ -78,3 +78,5 @@ end require_relative '../../../ee/spec/support/helpers/ee/stub_object_storage' if Dir.exist?("#{__dir__}/../../../ee") + +StubObjectStorage.prepend_if_ee('EE::StubObjectStorage') diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 8ca362ce2df..3274651ef19 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -418,3 +418,8 @@ module TestEnv true end end + +require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee? + +::TestEnv.prepend_if_ee('::EE::TestEnv') +::TestEnv.extend_if_ee('::EE::TestEnv') diff --git a/spec/support/helpers/workhorse_helpers.rb b/spec/support/helpers/workhorse_helpers.rb index fdbfe53fa39..40007a14b85 100644 --- a/spec/support/helpers/workhorse_helpers.rb +++ b/spec/support/helpers/workhorse_helpers.rb @@ -29,7 +29,8 @@ module WorkhorseHelpers post(url, params: workhorse_params, - headers: workhorse_rewritten_fields_header('file' => file.path) + headers: workhorse_rewritten_fields_header(file_key => file.path), + env: { 'CONTENT_TYPE' => 'multipart/form-data' } ) end |