summaryrefslogtreecommitdiff
path: root/spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
blob: 6d587053b4f81056260875fb839087c5e51ac59c (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'

describe 'Projects > Raw > User interacts with raw endpoint' do
  include RepoHelpers

  let(:user) { create(:user) }
  let(:project) { create(:project, :repository, :public) }
  let(:file_path) { 'master/README.md' }

  before do
    stub_application_setting(raw_blob_request_limit: 3)
    project.add_developer(user)
    create_file_in_repo(project, 'master', 'master', 'README.md', 'readme content')

    sign_in(user)
  end

  context 'when user access a raw file' do
    it 'renders the page successfully' do
      visit project_raw_url(project, file_path)

      expect(source).to eq('') # Body is filled in by gitlab-workhorse
    end
  end

  context 'when user goes over the rate requests limit' do
    it 'returns too many requests' do
      4.times do
        visit project_raw_url(project, file_path)
      end

      expect(source).to have_content('You are being redirected')
      click_link('redirected')
      expect(page).to have_content('You cannot access the raw file. Please wait a minute.')
    end
  end
end