summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb
blob: 2db03898e0143689e7c559fa525a33acd1642508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require 'fast_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/gitlab/avoid_uploaded_file_from_params'

RSpec.describe RuboCop::Cop::Gitlab::AvoidUploadedFileFromParams do
  include CopHelper

  subject(:cop) { described_class.new }

  context 'UploadedFile.from_params' do
    it 'flags its call' do
      expect_offense(<<~SOURCE)
      UploadedFile.from_params(params)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `UploadedFile` set by `multipart.rb` instead of calling `UploadedFile.from_params` directly. See https://docs.gitlab.com/ee/development/uploads.html#how-to-add-a-new-upload-route
      SOURCE
    end
  end
end