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

blob_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: b3321375ccc8936d2381001ed00980ebacfcbcdf (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
# frozen_string_literal: true

require 'spec_helper'

describe Projects::BlobController do
  let(:project) { create(:project, :private, :repository) }
  let(:namespace) { project.namespace }

  context 'anonymous user views blob in inaccessible project' do
    context 'with default HTML format' do
      before do
        get namespace_project_blob_path(namespace_id: namespace, project_id: project, id: 'master/README.md')
      end

      context 'when project is private' do
        it { expect(response).to have_gitlab_http_status(:redirect) }
      end

      context 'when project does not exist' do
        let(:namespace) { 'non_existent_namespace' }
        let(:project)   { 'non_existent_project' }

        it { expect(response).to have_gitlab_http_status(:redirect) }
      end
    end

    context 'with JSON format' do
      before do
        get namespace_project_blob_path(namespace_id: namespace, project_id: project, id: 'master/README.md', format: :json)
      end

      context 'when project is private' do
        it { expect(response).to have_gitlab_http_status(:unauthorized) }
      end

      context 'when project does not exist' do
        let(:namespace) { 'non_existent_namespace' }
        let(:project)   { 'non_existent_project' }

        it { expect(response).to have_gitlab_http_status(:unauthorized) }
      end
    end
  end
end