mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 23:05:48 +08:00
8ebd5edd1e
This commit renames all secure_media related settings to secure_uploads_* along with the associated functionality. This is being done because "media" does not really cover it, we aren't just doing this for images and videos etc. but for all uploads in the site. Additionally, in future we want to secure more types of uploads, and enable a kind of "mixed mode" where some uploads are secure and some are not, so keeping media in the name is just confusing. This also keeps compatibility with the `secure-media-uploads` path, and changes new secure URLs to be `secure-uploads`. Deprecated settings: * secure_media -> secure_uploads * secure_media_allow_embed_images_in_emails -> secure_uploads_allow_embed_images_in_emails * secure_media_max_email_embed_image_size_kb -> secure_uploads_max_email_embed_image_size_kb
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UploadSerializer do
|
|
fab!(:upload) { Fabricate(:upload) }
|
|
let(:subject) { UploadSerializer.new(upload, root: false) }
|
|
|
|
it 'should render without errors' do
|
|
json_data = JSON.parse(subject.to_json)
|
|
|
|
expect(json_data['id']).to eql upload.id
|
|
expect(json_data['width']).to eql upload.width
|
|
expect(json_data['height']).to eql upload.height
|
|
expect(json_data['thumbnail_width']).to eql upload.thumbnail_width
|
|
expect(json_data['thumbnail_height']).to eql upload.thumbnail_height
|
|
expect(json_data['short_path']).to eql upload.short_path
|
|
end
|
|
|
|
context "when the upload is secure" do
|
|
fab!(:upload) { Fabricate(:secure_upload) }
|
|
|
|
context "when secure uploads is disabled" do
|
|
it "just returns the normal URL, otherwise S3 errors are encountered" do
|
|
UrlHelper.expects(:cook_url).with(upload.url, secure: false)
|
|
subject.to_json
|
|
end
|
|
end
|
|
|
|
context "when secure uploads is enabled" do
|
|
before do
|
|
setup_s3
|
|
SiteSetting.secure_uploads = true
|
|
end
|
|
|
|
it "returns the cooked URL based on the upload URL" do
|
|
UrlHelper.expects(:cook_url).with(upload.url, secure: true)
|
|
subject.to_json
|
|
end
|
|
end
|
|
end
|
|
end
|