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

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

30 lines
858 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Resolvers::Projects::GrafanaIntegrationResolver do
2020-03-13 15:44:24 +05:30
include GraphqlHelpers
let_it_be(:project) { create(:project) }
let_it_be(:current_user) { create(:user) }
2022-08-27 11:52:29 +05:30
let_it_be(:grafana_integration) { create(:grafana_integration, project: project) }
2020-03-13 15:44:24 +05:30
describe '#resolve' do
context 'when object is not a project' do
it { expect(resolve_integration(obj: current_user)).to eq nil }
end
context 'when object is a project' do
it { expect(resolve_integration(obj: project)).to eq grafana_integration }
end
context 'when object is nil' do
2022-08-27 11:52:29 +05:30
it { expect(resolve_integration(obj: nil)).to eq nil }
2020-03-13 15:44:24 +05:30
end
end
def resolve_integration(obj: project, context: { current_user: current_user })
resolve(described_class, obj: obj, ctx: context)
end
end