diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-09 21:09:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-09 21:09:48 +0300 |
commit | 9b09561f47159655d05171b4bee980c669859864 (patch) | |
tree | 06a273b8ee38d644ab6a45c2c78856cb38c756e8 /spec/graphql | |
parent | e91cb68359c900aa51ffdb1863502168742e94f0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/mutations/boards/issues/issue_move_list_spec.rb | 12 | ||||
-rw-r--r-- | spec/graphql/resolvers/board_lists_resolver_spec.rb | 12 | ||||
-rw-r--r-- | spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb | 2 | ||||
-rw-r--r-- | spec/graphql/resolvers/snippets/blobs_resolver_spec.rb | 26 | ||||
-rw-r--r-- | spec/graphql/types/ci/pipeline_type_spec.rb | 15 | ||||
-rw-r--r-- | spec/graphql/types/commit_type_spec.rb | 2 | ||||
-rw-r--r-- | spec/graphql/types/merge_request_type_spec.rb | 9 | ||||
-rw-r--r-- | spec/graphql/types/project_type_spec.rb | 2 |
8 files changed, 47 insertions, 33 deletions
diff --git a/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb b/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb index ded5776b3cb..24104a20465 100644 --- a/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb +++ b/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb @@ -73,18 +73,6 @@ RSpec.describe Mutations::Boards::Issues::IssueMoveList do it_behaves_like 'raises a resource not available error' end - - context 'when user cannot access board' do - let(:board) { create(:board, group: create(:group, :private)) } - - it_behaves_like 'raises a resource not available error' - end - - context 'when passing board_id as nil' do - let(:board) { nil } - - it_behaves_like 'raises a resource not available error' - end end end end diff --git a/spec/graphql/resolvers/board_lists_resolver_spec.rb b/spec/graphql/resolvers/board_lists_resolver_spec.rb index c1d8041a1e0..71ebec4dc7e 100644 --- a/spec/graphql/resolvers/board_lists_resolver_spec.rb +++ b/spec/graphql/resolvers/board_lists_resolver_spec.rb @@ -29,9 +29,7 @@ RSpec.describe Resolvers::BoardListsResolver do context 'with unauthorized user' do it 'raises an error' do - expect do - resolve_board_lists(current_user: unauth_user) - end.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + expect(resolve_board_lists(current_user: unauth_user)).to be_nil end end @@ -101,12 +99,6 @@ RSpec.describe Resolvers::BoardListsResolver do end def resolve_board_lists(args: {}, current_user: user) - context = GraphQL::Query::Context.new( - query: OpenStruct.new(schema: nil), - values: { current_user: current_user }, - object: nil - ) - - resolve(described_class, obj: board, args: args, ctx: context ) + resolve(described_class, obj: board, args: args, ctx: { current_user: current_user }) end end diff --git a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb index deb5ff584cf..84ef906b72f 100644 --- a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Resolvers::MergeRequestPipelinesResolver do end def resolve_pipelines - resolve(described_class, obj: merge_request, ctx: { current_user: current_user }) + sync(resolve(described_class, obj: merge_request, ctx: { current_user: current_user })) end it 'resolves only MRs for the passed merge request' do diff --git a/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb b/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb index 16e69f662c0..ebe286769cf 100644 --- a/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb +++ b/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb @@ -16,16 +16,18 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do context 'when user is not authorized' do let(:other_user) { create(:user) } - it 'raises an error' do - expect do - resolve_blobs(snippet, user: other_user) - end.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + it 'redacts the field' do + expect(resolve_blobs(snippet, user: other_user)).to be_nil end end context 'when using no filter' do it 'returns all snippet blobs' do - expect(resolve_blobs(snippet).map(&:path)).to contain_exactly(*snippet.list_files) + result = resolve_blobs(snippet, args: {}) + + expect(result).to match_array(snippet.list_files.map do |file| + have_attributes(path: file) + end) end end @@ -34,7 +36,13 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do it 'returns an array of files' do path = 'CHANGELOG' - expect(resolve_blobs(snippet, args: { paths: path }).first.path).to eq(path) + expect(resolve_blobs(snippet, paths: [path])).to contain_exactly(have_attributes(path: path)) + end + end + + context 'the argument does not match anything' do + it 'returns an empty result' do + expect(resolve_blobs(snippet, paths: ['does not exist'])).to be_empty end end @@ -42,13 +50,15 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do it 'returns an array of files' do paths = ['CHANGELOG', 'README.md'] - expect(resolve_blobs(snippet, args: { paths: paths }).map(&:path)).to contain_exactly(*paths) + expect(resolve_blobs(snippet, paths: paths)).to match_array(paths.map do |file| + have_attributes(path: file) + end) end end end end - def resolve_blobs(snippet, user: current_user, args: {}) + def resolve_blobs(snippet, user: current_user, paths: [], args: { paths: paths }) resolve(described_class, args: args, ctx: { current_user: user }, obj: snippet) end end diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index f13f1c9afb2..d435e337ad7 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -6,4 +6,19 @@ RSpec.describe Types::Ci::PipelineType do specify { expect(described_class.graphql_name).to eq('Pipeline') } specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) } + + it 'contains attributes related to a pipeline' do + expected_fields = %w[ + id iid sha before_sha status detailed_status config_source duration + coverage created_at updated_at started_at finished_at committed_at + stages user retryable cancelable jobs source_job downstream + upstream path project active user_permissions + ] + + if Gitlab.ee? + expected_fields << 'security_report_summary' + end + + expect(described_class).to have_graphql_fields(*expected_fields) + end end diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index e9bc7f6bb94..b43693e5804 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Commit'] do it 'contains attributes related to commit' do expect(described_class).to have_graphql_fields( - :id, :sha, :title, :description, :description_html, :message, :title_html, :authored_date, + :id, :sha, :short_id, :title, :description, :description_html, :message, :title_html, :authored_date, :author_name, :author_gravatar, :author, :web_url, :web_path, :pipelines, :signature_html ) diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index c929a93a9eb..68387bbc82e 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -28,17 +28,26 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do milestone assignees participants subscribed labels discussion_locked time_estimate total_time_spent reference author merged_at commit_count current_user_todos conflicts auto_merge_enabled approved_by source_branch_protected + default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies + has_ci mergeable commits_without_merge_commits ] if Gitlab.ee? expected_fields << 'approved' expected_fields << 'approvals_left' expected_fields << 'approvals_required' + expected_fields << 'merge_trains_count' end expect(described_class).to have_graphql_fields(*expected_fields) end + describe '#pipelines' do + subject { described_class.fields['pipelines'] } + + it { is_expected.to have_attributes(max_page_size: 500) } + end + describe '#diff_stats_summary' do subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json } diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index ff99dd77233..3fcdf910e98 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -31,7 +31,7 @@ RSpec.describe GitlabSchema.types['Project'] do container_expiration_policy service_desk_enabled service_desk_address issue_status_counts terraform_states alert_management_integrations container_repositories container_repositories_count - pipeline_analytics total_pipeline_duration + pipeline_analytics total_pipeline_duration squash_read_only ] expect(described_class).to include_graphql_fields(*expected_fields) |