From e2ee1eec50aa8df8543d7ecc585ec0ba5ee544ac Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 8 Apr 2020 03:09:31 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/support/helpers/graphql_helpers.rb | 3 ++- spec/support/import_export/common_util.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'spec/support') diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 1bb942ff39b..74582df6cd9 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -378,8 +378,9 @@ module GraphqlHelpers def execute_query(query_type) schema = Class.new(GraphQL::Schema) do + use GraphQL::Pagination::Connections use Gitlab::Graphql::Authorize - use Gitlab::Graphql::Connections + use Gitlab::Graphql::Pagination::Connections query(query_type) end diff --git a/spec/support/import_export/common_util.rb b/spec/support/import_export/common_util.rb index efe14b7244c..16762f32d8b 100644 --- a/spec/support/import_export/common_util.rb +++ b/spec/support/import_export/common_util.rb @@ -15,9 +15,39 @@ module ImportExport export_path = [prefix, 'spec', 'fixtures', 'lib', 'gitlab', 'import_export', name].compact export_path = File.join(*export_path) + extract_archive(export_path, 'tree.tar.gz') + allow_any_instance_of(Gitlab::ImportExport).to receive(:export_path) { export_path } end + def extract_archive(path, archive) + if File.exist?(File.join(path, archive)) + system("cd #{path}; tar xzvf #{archive} &> /dev/null") + end + end + + def cleanup_artifacts_from_extract_archive(name, prefix = nil) + export_path = [prefix, 'spec', 'fixtures', 'lib', 'gitlab', 'import_export', name].compact + export_path = File.join(*export_path) + + if File.exist?(File.join(export_path, 'tree.tar.gz')) + system("cd #{export_path}; rm -fr tree &> /dev/null") + end + end + + def setup_reader(reader) + case reader + when :legacy_reader + allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(true) + allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(false) + when :ndjson_reader + allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(false) + allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(true) + else + raise "invalid reader #{reader}. Supported readers: :legacy_reader, :ndjson_reader" + end + end + def fixtures_path "spec/fixtures/lib/gitlab/import_export" end -- cgit v1.2.1