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

file_uploads_spec.rb « scalability « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed826728681bff5abf24fcd7f7d096a99866db66 (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
# frozen_string_literal: true

require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../../rubocop/cop/scalability/file_uploads'

RSpec.describe RuboCop::Cop::Scalability::FileUploads, type: :rubocop do
  include CopHelper

  subject(:cop) { described_class.new }

  let(:message) { 'Do not upload files without workhorse acceleration. Please refer to https://docs.gitlab.com/ee/development/uploads.html' }

  context 'with required params' do
    it 'detects File in types array' do
      expect_offense(<<~PATTERN)
      params do
        requires :certificate, allow_blank: false, types: [String, File]
                                                                   ^^^^ #{message}
      end
      PATTERN
    end

    it 'detects File as type argument' do
      expect_offense(<<~PATTERN)
      params do
        requires :attachment, type: File
                                    ^^^^ #{message}
      end
      PATTERN
    end
  end

  context 'with optional params' do
    it 'detects File in types array' do
      expect_offense(<<~PATTERN)
      params do
        optional :certificate, allow_blank: false, types: [String, File]
                                                                   ^^^^ #{message}
      end
      PATTERN
    end

    it 'detects File as type argument' do
      expect_offense(<<~PATTERN)
      params do
        optional :attachment, type: File
                                    ^^^^ #{message}
      end
      PATTERN
    end
  end
end