diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 00:08:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 00:08:08 +0300 |
commit | e0b84f4ba4b44c8ecf00be97843c40df2550b74c (patch) | |
tree | 7cecae4276358dd46d7fa15f84068f7b4c626089 /spec/graphql | |
parent | 73391dcc368ef846c2960c1d0ef5e64ca78e1bee (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/gitlab_schema_spec.rb | 16 | ||||
-rw-r--r-- | spec/graphql/types/query_type_spec.rb | 11 |
2 files changed, 24 insertions, 3 deletions
diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb index dcf3c989047..2ec477fc494 100644 --- a/spec/graphql/gitlab_schema_spec.rb +++ b/spec/graphql/gitlab_schema_spec.rb @@ -124,14 +124,26 @@ describe GitlabSchema do describe '.object_from_id' do context 'for subclasses of `ApplicationRecord`' do - it 'returns the correct record' do - user = create(:user) + let_it_be(:user) { create(:user) } + it 'returns the correct record' do result = described_class.object_from_id(user.to_global_id.to_s) expect(result.sync).to eq(user) end + it 'returns the correct record, of the expected type' do + result = described_class.object_from_id(user.to_global_id.to_s, expected_type: ::User) + + expect(result.sync).to eq(user) + end + + it 'fails if the type does not match' do + expect do + described_class.object_from_id(user.to_global_id.to_s, expected_type: ::Project) + end.to raise_error(Gitlab::Graphql::Errors::ArgumentError) + end + it 'batchloads the queries' do user1 = create(:user) user2 = create(:user) diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index b2d0ba27d4e..39a363cb913 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -7,7 +7,16 @@ describe GitlabSchema.types['Query'] do expect(described_class.graphql_name).to eq('Query') end - it { is_expected.to have_graphql_fields(:project, :namespace, :group, :echo, :metadata, :current_user, :snippets) } + it do + is_expected.to have_graphql_fields(:project, + :namespace, + :group, + :echo, + :metadata, + :current_user, + :snippets + ).at_least + end describe 'namespace field' do subject { described_class.fields['namespace'] } |