2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
require 'rubocop_spec_helper'
|
2019-12-04 20:38:33 +05:30
|
|
|
require_relative '../../../../rubocop/cop/scalability/file_uploads'
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
RSpec.describe RuboCop::Cop::Scalability::FileUploads, feature_category: :scalability do
|
2019-12-04 20:38:33 +05:30
|
|
|
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-06-23 00:09:42 +05:30
|
|
|
expect_offense(<<~PATTERN)
|
2019-12-04 20:38:33 +05:30
|
|
|
params do
|
|
|
|
requires :certificate, allow_blank: false, types: [String, File]
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects File as type argument' do
|
2020-06-23 00:09:42 +05:30
|
|
|
expect_offense(<<~PATTERN)
|
2019-12-04 20:38:33 +05:30
|
|
|
params do
|
|
|
|
requires :attachment, type: File
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with optional params' do
|
|
|
|
it 'detects File in types array' do
|
2020-06-23 00:09:42 +05:30
|
|
|
expect_offense(<<~PATTERN)
|
2019-12-04 20:38:33 +05:30
|
|
|
params do
|
|
|
|
optional :certificate, allow_blank: false, types: [String, File]
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects File as type argument' do
|
2020-06-23 00:09:42 +05:30
|
|
|
expect_offense(<<~PATTERN)
|
2019-12-04 20:38:33 +05:30
|
|
|
params do
|
|
|
|
optional :attachment, type: File
|
|
|
|
^^^^ #{message}
|
|
|
|
end
|
|
|
|
PATTERN
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|