summaryrefslogtreecommitdiff
path: root/spec/lib/sentry/client/repo_spec.rb
blob: 956c0b6eee189a73d486ea59d54390733f90eb04 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sentry::Client::Repo do
  include SentryClientHelpers

  let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
  let(:token) { 'test-token' }
  let(:client) { Sentry::Client.new(sentry_url, token) }
  let(:repos_sample_response) { Gitlab::Json.parse(fixture_file('sentry/repos_sample_response.json')) }

  describe '#repos' do
    let(:organization_slug) { 'gitlab' }
    let(:sentry_repos_url) { "https://sentrytest.gitlab.com/api/0/organizations/#{organization_slug}/repos/" }
    let(:sentry_api_response) { repos_sample_response }
    let!(:sentry_api_request) { stub_sentry_request(sentry_repos_url, body: sentry_api_response) }

    subject { client.repos(organization_slug) }

    it_behaves_like 'calls sentry api'

    it { is_expected.to all( be_a(Gitlab::ErrorTracking::Repo)) }

    it { expect(subject.length).to eq(1) }

    context 'redirects' do
      let(:sentry_api_url) { sentry_repos_url }

      it_behaves_like 'no Sentry redirects'
    end

    context 'when exception is raised' do
      let(:sentry_request_url) { sentry_repos_url }

      it_behaves_like 'maps Sentry exceptions'
    end
  end
end