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

tracing_controller_spec.rb « projects « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eecaa0d962ab22ba82091c1d013cf4b2298b4fd3 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::TracingController, feature_category: :tracing do
  let_it_be(:group) { create(:group) }
  let_it_be(:project) { create(:project, group: group) }
  let_it_be(:user) { create(:user) }
  let(:path) { nil }
  let(:observability_tracing_ff) { true }

  subject do
    get path
    response
  end

  describe 'GET #index' do
    before do
      stub_feature_flags(observability_tracing: observability_tracing_ff)
      sign_in(user)
    end

    let(:path) { project_tracing_index_path(project) }

    it_behaves_like 'observability csp policy' do
      before_all do
        project.add_developer(user)
      end

      let(:tested_path) { path }
    end

    context 'when user does not have permissions' do
      it 'returns 404' do
        expect(subject).to have_gitlab_http_status(:not_found)
      end
    end

    context 'when user has permissions' do
      before_all do
        project.add_developer(user)
      end

      it 'returns 200' do
        expect(subject).to have_gitlab_http_status(:ok)
      end

      it 'renders the js-tracing element correctly' do
        element = Nokogiri::HTML.parse(subject.body).at_css('#js-tracing')

        expected_view_model = {
          tracingUrl: Gitlab::Observability.tracing_url(project),
          provisioningUrl: Gitlab::Observability.provisioning_url(project),
          oauthUrl: Gitlab::Observability.oauth_url
        }.to_json
        expect(element.attributes['data-view-model'].value).to eq(expected_view_model)
      end

      context 'when feature is disabled' do
        let(:observability_tracing_ff) { false }

        it 'returns 404' do
          expect(subject).to have_gitlab_http_status(:not_found)
        end
      end
    end
  end
end