debian-mirror-gitlab/spec/graphql/resolvers/project_resolver_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Resolvers::ProjectResolver do
2018-11-08 19:23:39 +05:30
include GraphqlHelpers
2020-04-08 14:13:33 +05:30
let_it_be(:project1) { create(:project) }
let_it_be(:project2) { create(:project) }
let_it_be(:other_project) { create(:project) }
2018-11-08 19:23:39 +05:30
describe '#resolve' do
it 'batch-resolves projects by full path' do
paths = [project1.full_path, project2.full_path]
2019-12-04 20:38:33 +05:30
result = batch_sync(max_queries: 1) do
2018-11-08 19:23:39 +05:30
paths.map { |path| resolve_project(path) }
end
expect(result).to contain_exactly(project1, project2)
end
it 'resolves an unknown full_path to nil' do
2019-12-04 20:38:33 +05:30
result = batch_sync { resolve_project('unknown/project') }
2018-11-08 19:23:39 +05:30
expect(result).to be_nil
end
2021-11-11 11:23:49 +05:30
it 'treats project full path as case insensitive' do
result = batch_sync { resolve_project(project1.full_path.upcase) }
expect(result).to eq project1
end
2018-11-08 19:23:39 +05:30
end
2019-07-31 22:56:46 +05:30
it 'does not increase complexity depending on number of load limits' do
2021-10-27 15:23:28 +05:30
field1 = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 100)
field2 = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 1)
2019-07-31 22:56:46 +05:30
2022-05-07 20:08:51 +05:30
expect(field1.complexity.call({}, {}, 1)).to eq 2
expect(field2.complexity.call({}, {}, 1)).to eq 2
2019-07-31 22:56:46 +05:30
end
2018-11-08 19:23:39 +05:30
def resolve_project(full_path)
resolve(described_class, args: { full_path: full_path })
end
end