FIX: Provide better API for registering custom upload public types (#10697)

With secure media and the UploadSecurity class, we need a nice way for plugins to register custom upload types that should be considered public and never secure.
This commit is contained in:
Martin Brennan
2020-09-18 11:54:33 +10:00
committed by GitHub
parent 22181f59ab
commit 14b324e5ed
2 changed files with 27 additions and 4 deletions

View File

@ -64,6 +64,18 @@ RSpec.describe UploadSecurity do
expect(subject.should_be_secure?).to eq(false)
end
end
describe "for a custom public type" do
let(:type) { 'my_custom_type' }
it "returns true if the custom type has not been added" do
expect(subject.should_be_secure?).to eq(true)
end
it "returns false if the custom type has been added" do
UploadSecurity.register_custom_public_type(type)
expect(subject.should_be_secure?).to eq(false)
end
end
describe "for_theme" do
before do
upload.stubs(:for_theme).returns(true)