discourse/spec/jobs/regular/update_post_uploads_secure_status_spec.rb
Daniel Waterworth 6e161d3e75
DEV: Allow fab! without block (#24314)
The most common thing that we do with fab! is:

    fab!(:thing) { Fabricate(:thing) }

This commit adds a shorthand for this which is just simply:

    fab!(:thing)

i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
2023-11-09 16:47:59 -06:00

38 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require "rails_helper"
RSpec.describe Jobs::UpdatePostUploadsSecureStatus do
fab!(:post)
before do
UploadReference.create!(target: post, upload: Fabricate(:upload))
UploadReference.create!(target: post, upload: Fabricate(:upload))
end
context "when secure uploads is enabled" do
before do
setup_s3
stub_s3_store
SiteSetting.secure_uploads = 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.upload_references.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.upload_references.map(&:upload).map(&:secure).all?(true)).to eq(true)
end
end
end
end