2019-09-10 12:24:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'fast_spec_helper'
|
|
|
|
require_relative '../../../../rubocop/cop/scalability/file_uploads'
|
|
|
|
|
2021-01-07 13:10:38 -05:00
|
|
|
RSpec.describe RuboCop::Cop::Scalability::FileUploads do
|
2019-09-10 12:24:10 -04:00
|
|
|
subject(:cop) { described_class.new }
|
2019-10-18 07:11:44 -04:00
|
|
|
|
2019-09-10 12:24:10 -04:00
|
|
|
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
|
2020-05-28 17:08:22 -04:00
|
|
|
expect_offense(<<~PATTERN)
|
2019-09-10 12:24:10 -04:00
|
|
|
params do
|
|
|
|
requires :certificate, allow_blank: false, types: [String, File]
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects File as type argument' do
|
2020-05-28 17:08:22 -04:00
|
|
|
expect_offense(<<~PATTERN)
|
2019-09-10 12:24:10 -04:00
|
|
|
params do
|
|
|
|
requires :attachment, type: File
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with optional params' do
|
|
|
|
it 'detects File in types array' do
|
2020-05-28 17:08:22 -04:00
|
|
|
expect_offense(<<~PATTERN)
|
2019-09-10 12:24:10 -04:00
|
|
|
params do
|
|
|
|
optional :certificate, allow_blank: false, types: [String, File]
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects File as type argument' do
|
2020-05-28 17:08:22 -04:00
|
|
|
expect_offense(<<~PATTERN)
|
2019-09-10 12:24:10 -04:00
|
|
|
params do
|
|
|
|
optional :attachment, type: File
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|