2022-04-20 00:11:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Jobs::UpdatePostUploadsSecureStatus do
|
2022-04-20 00:11:39 -04:00
|
|
|
fab!(:post) { Fabricate(:post) }
|
|
|
|
|
|
|
|
before do
|
2022-06-08 19:24:30 -04:00
|
|
|
UploadReference.create!(target: post, upload: Fabricate(:upload))
|
|
|
|
UploadReference.create!(target: post, upload: Fabricate(:upload))
|
2022-04-20 00:11:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when secure uploads is enabled" do
|
|
|
|
before do
|
|
|
|
setup_s3
|
|
|
|
stub_s3_store
|
2022-09-28 19:24:33 -04:00
|
|
|
SiteSetting.secure_uploads = true
|
2022-04-20 00:11:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when login_required" do
|
|
|
|
before { SiteSetting.login_required = true }
|
|
|
|
|
|
|
|
it "updates all the uploads to secure" do
|
|
|
|
described_class.new.execute(post_id: post.id)
|
|
|
|
post.reload
|
2022-06-08 19:24:30 -04:00
|
|
|
expect(post.upload_references.map(&:upload).map(&:secure).all?(true)).to eq(true)
|
2022-04-20 00:11:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "updates all the uploads to secure even if their extension is not authorized" do
|
|
|
|
SiteSetting.authorized_extensions = ""
|
|
|
|
described_class.new.execute(post_id: post.id)
|
|
|
|
post.reload
|
2022-06-08 19:24:30 -04:00
|
|
|
expect(post.upload_references.map(&:upload).map(&:secure).all?(true)).to eq(true)
|
2022-04-20 00:11:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|