summaryrefslogtreecommitdiff
path: root/spec/graphql/resolvers/error_tracking/sentry_error_collection_resolver_spec.rb
blob: 20c2bdcd4e1a77545c57213b836305198d4a3f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Resolvers::ErrorTracking::SentryErrorCollectionResolver do
  include GraphqlHelpers

  let_it_be(:project) { create(:project) }
  let_it_be(:current_user) { create(:user) }

  let(:list_issues_service) { spy('ErrorTracking::ListIssuesService') }

  specify do
    expect(described_class).to have_nullable_graphql_type(Types::ErrorTracking::SentryErrorCollectionType)
  end

  before do
    project.add_developer(current_user)

    allow(ErrorTracking::ListIssuesService)
      .to receive(:new)
      .and_return list_issues_service
  end

  describe '#resolve' do
    it 'returns an error collection object' do
      expect(resolve_error_collection).to be_a Gitlab::ErrorTracking::ErrorCollection
    end

    it 'provides the service url' do
      fake_url = 'http://test.com'

      expect(list_issues_service)
        .to receive(:external_url)
        .and_return(fake_url)

      result = resolve_error_collection
      expect(result.external_url).to eq fake_url
    end

    it 'provides the project' do
      expect(resolve_error_collection.project).to eq project
    end
  end

  private

  def resolve_error_collection(context = { current_user: current_user })
    resolve(described_class, obj: project, args: {}, ctx: context)
  end
end