diff options
Diffstat (limited to 'spec/support/helpers/javascript_fixtures_helpers.rb')
-rw-r--r-- | spec/support/helpers/javascript_fixtures_helpers.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index 8fd8a548011..4c90b907d2d 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -43,12 +43,14 @@ module JavaScriptFixturesHelpers # Public: Reads a GraphQL query from the filesystem as a string # # query_path - file path to the GraphQL query, relative to `app/assets/javascripts` - # fragment_paths - an optional array of file paths to any fragments the query uses, - # also relative to `app/assets/javascripts` - def get_graphql_query_as_string(query_path, fragment_paths = []) - [query_path, *fragment_paths].map do |path| - File.read(File.join(Rails.root, '/app/assets/javascripts', path)) - end.join("\n") + def get_graphql_query_as_string(query_path) + path = Rails.root / 'app/assets/javascripts' / query_path + queries = Gitlab::Graphql::Queries.find(path) + if queries.length == 1 + queries.first.text(mode: Gitlab.ee? ? :ee : :ce ) + else + raise "Could not find query file at #{path}, please check your query_path" % path + end end private |