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:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-03 03:07:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-03 03:07:15 +0300
commit25ba0c04e90a470bfdf3fe3a5b044a73157565d2 (patch)
tree9589a405ba956edeaa6d92a4fedbd3a1b422c793 /spec/requests/api/graphql
parent3a72ac775065b61bbdb285a8f4f6f152ccb4db49 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/graphql')
-rw-r--r--spec/requests/api/graphql/organizations/organizations_query_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/organizations/organizations_query_spec.rb b/spec/requests/api/graphql/organizations/organizations_query_spec.rb
new file mode 100644
index 00000000000..12d81ed7412
--- /dev/null
+++ b/spec/requests/api/graphql/organizations/organizations_query_spec.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'getting organizations information', feature_category: :cell do
+ include GraphqlHelpers
+
+ let_it_be(:user) { create(:user) }
+
+ let(:query) { graphql_query_for(:organizations, organizations_fields) }
+ let(:organizations) { graphql_data_at(:organizations, :nodes) }
+ let(:organizations_fields) do
+ <<~FIELDS
+ nodes {
+ id
+ path
+ }
+ FIELDS
+ end
+
+ before_all { create_list(:organization, 3) }
+
+ subject(:request_organization) { post_graphql(query, current_user: current_user) }
+
+ context 'without authenticated user' do
+ let(:current_user) { nil }
+
+ it_behaves_like 'a working graphql query' do
+ before do
+ request_organization
+ end
+ end
+ end
+
+ context 'with authenticated user' do
+ let(:current_user) { user }
+
+ it_behaves_like 'a working graphql query' do
+ before do
+ request_organization
+ end
+ end
+
+ it_behaves_like 'sorted paginated query' do
+ include_context 'no sort argument'
+
+ let(:first_param) { 2 }
+ let(:data_path) { [:organizations] }
+ let(:all_records) { Organizations::Organization.order(id: :desc).map { |o| global_id_of(o).to_s } }
+ end
+
+ def pagination_query(params)
+ graphql_query_for(:organizations, params, "#{page_info} nodes { id }")
+ end
+ end
+end