debian-mirror-gitlab/spec/graphql/resolvers/projects/services_resolver_spec.rb

77 lines
1.9 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Resolvers::Projects::ServicesResolver do
2020-04-22 19:07:51 +05:30
include GraphqlHelpers
2021-01-29 00:20:46 +05:30
specify do
expect(described_class).to have_nullable_graphql_type(Types::Projects::ServiceType.connection_type)
end
2020-04-22 19:07:51 +05:30
describe '#resolve' do
let_it_be(:user) { create(:user) }
context 'when project does not have services' do
let_it_be(:project) { create(:project, :private) }
context 'when user cannot access services' do
context 'when anonymous user' do
it_behaves_like 'cannot access project services'
end
context 'when user developer' do
before do
project.add_developer(user)
end
it_behaves_like 'cannot access project services'
end
end
context 'when user can read project services' do
before do
project.add_maintainer(user)
end
it_behaves_like 'no project services'
end
end
context 'when project has services' do
let_it_be(:project) { create(:project, :private) }
2021-09-30 23:02:18 +05:30
let_it_be(:jira_integration) { create(:jira_integration, project: project) }
2020-04-22 19:07:51 +05:30
context 'when user cannot access services' do
context 'when anonymous user' do
it_behaves_like 'cannot access project services'
end
context 'when user developer' do
before do
project.add_developer(user)
end
it_behaves_like 'cannot access project services'
end
end
context 'when user can read project services' do
before do
project.add_maintainer(user)
end
it 'returns project services' do
services = resolve_services
expect(services.size).to eq 1
end
end
end
end
def resolve_services(args = {}, context = { current_user: user })
resolve(described_class, obj: project, args: args, ctx: context)
end
end