Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sentry_error_collection_resolver_spec.rb « error_tracking « resolvers « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5834faea97e97c7a597e356f3235b16c4a55da49 (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
52
53
54
# 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) { instance_double('ErrorTracking::ListIssuesService') }

  before_all do
    project.add_developer(current_user)
  end

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

    allow(list_issues_service).to receive(:external_url)
  end

  specify do
    expect(described_class).to have_nullable_graphql_type(Types::ErrorTracking::SentryErrorCollectionType)
  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)

      expect(resolve_error_collection.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