Commit 94b29be5 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'leaky-constant-fix-2' into 'master'

Stub class in content whitelist spec

See merge request gitlab-org/gitlab!31946
parents 13607270 6635dc0a
...@@ -404,7 +404,6 @@ RSpec/LeakyConstantDeclaration: ...@@ -404,7 +404,6 @@ RSpec/LeakyConstantDeclaration:
- 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb' - 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb'
- 'spec/support_specs/helpers/active_record/query_recorder_spec.rb' - 'spec/support_specs/helpers/active_record/query_recorder_spec.rb'
- 'spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb' - 'spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb'
- 'spec/uploaders/content_type_whitelist_spec.rb'
- 'spec/uploaders/records_uploads_spec.rb' - 'spec/uploaders/records_uploads_spec.rb'
RSpec/EmptyLineAfterHook: RSpec/EmptyLineAfterHook:
......
---
title: Add class stubs and fix leaky constant alert in content whitelist spec
merge_request: 31946
author: Rajendra Kadam
type: fixed
...@@ -3,16 +3,20 @@ ...@@ -3,16 +3,20 @@
require 'spec_helper' require 'spec_helper'
describe ContentTypeWhitelist do describe ContentTypeWhitelist do
class DummyUploader < CarrierWave::Uploader::Base let_it_be(:model) { build_stubbed(:user) }
include ContentTypeWhitelist::Concern let!(:uploader) do
stub_const('DummyUploader', Class.new(CarrierWave::Uploader::Base))
DummyUploader.class_eval do
include ContentTypeWhitelist::Concern
def content_type_whitelist def content_type_whitelist
%w[image/png image/jpeg] %w[image/png image/jpeg]
end
end end
end
let_it_be(:model) { build_stubbed(:user) } DummyUploader.new(model, :dummy)
let_it_be(:uploader) { DummyUploader.new(model, :dummy) } end
context 'upload whitelisted file content type' do context 'upload whitelisted file content type' do
let(:path) { File.join('spec', 'fixtures', 'rails_sample.jpg') } let(:path) { File.join('spec', 'fixtures', 'rails_sample.jpg') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment