discourse/spec/jobs/ensure_s3_uploads_existence_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

39 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Jobs::EnsureS3UploadsExistence do
context "S3 inventory enabled" do
before do
setup_s3
SiteSetting.enable_s3_inventory = true
end
it "works" do
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).once
subject.execute({})
end
it "doesn't execute when the site was restored within the last 48 hours" do
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).never
BackupMetadata.update_last_restore_date(47.hours.ago)
subject.execute({})
end
it "executes when the site was restored more than 48 hours ago" do
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).once
BackupMetadata.update_last_restore_date(49.hours.ago)
subject.execute({})
end
end
context "S3 inventory disabled" do
before { SiteSetting.enable_s3_inventory = false }
it "doesn't execute" do
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).never
subject.execute({})
end
end
end