discourse/spec/jobs/regular/update_post_uploads_secure_...

38 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe Jobs::UpdatePostUploadsSecureStatus do
fab!(:post) { Fabricate(:post) }
before do
PostUpload.create!(post: post, upload: Fabricate(:upload))
PostUpload.create!(post: post, upload: Fabricate(:upload))
end
context "when secure uploads is enabled" do
before do
setup_s3
stub_s3_store
SiteSetting.secure_media = true
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
expect(post.post_uploads.map(&:upload).map(&:secure).all?(true)).to eq(true)
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
expect(post.post_uploads.map(&:upload).map(&:secure).all?(true)).to eq(true)
end
end
end
end